This page describes how to set up a WordPress blogging site, residing on AWS. Many years ago, I wrote a similar article on how to set up a WordPress site on Heroku. This time around, I decided to go with AWS EC2 as opposed with Heroku. Heroku has a great development set up, but I found the file system a bit restrictive to get some of the options working within WordPress. If you have basic unix skills, EC2 has more flexibility as it allows administatrative control over your instance and site.
You don’t need to do this, but I first installed everything on my local computer before pushing to EC2. I’m using macOS Sierra 10.12.1. You can jump to Step 4 – Configure Amazon EC2.
1. Install homebrew, apache, php using brew. Follow this article.
$ sudo apachectl start
2. Install mysql
$ brew install -v mysql $ mysql.server start $ mysql_secure_installation
Log into mysql to create a database and specify root at 127.0.0.1 user.
$ mysql -uroot -p > create user 'root'@'127.0.0.1' IDENTIFIED BY ''; > select User,Host from mysql.user; > grant all privileges on *.* to 'root'@'127.0.0.1'; > flush privileges; > create database <mywordpressdbname>; > exit;
3. Install wordpress
$ brew install wp-cli $ mkdir $ cd $ wp core download
3A. Install MySQL workbench. If needed, install MySQL workbench in order to modify SQL servers.
$ brew cask install mysqlworkbench
To install mysql-utilities which work with mysqlworkbench
$ brew cask install mysql-connector-python
Download Platform Independent version, and install MySQL Utilities
$ tar -xvf mysql-utilities-1.5.6.tar.gz $ cd mysql-utilities-1.5.6/ $ python ./setup.py build $ sudo python ./setup.py install
4. Configure Amazon EC2
Read this article first, and follow steps 1-3.
Step 1. Create an AWS account here.
Step 2. Create an EC2 instance. Don’t forget to create an elastic URL.
Step 3. SSH into instance.
The next steps 4 & 5, differ from the article.
Step 4: Install Apache.
For all the bells and whistles of WordPress 4.7, you’ll need the version 2.4.
$ sudo yum install -y httpd24 $ sudo service httpd start
Double check your AWS instance, using your assigned public DNS name (elastic URL). If you get a message permission denied, then go to the AWS Console and setup, under NETWORK & SECURITY, make sure your security group has the following info:
HTTP TCP 80 Source:0.0.0.0/0 SSH TCP 22 Source:
$ sudo service httpd restart
To make things easier, you can update httpd.conf to change the DocumentRoot so that you can work from your /home/ec2-user/Sites folder.
$ sudo vi /etc/httpd/conf/httpd.conf # Replace "/var/www/html" with "/home/ec2-user/Sites". # The changes are in two places. DocumentRoot "/home/ec2-user/Sites" ## Configuring working directory path # Also under your working directory path. # Enable AllowOverride which is needed for perma-links in WordPress. # AllowOverride controls what directives may be placed in .htaccess files. AllowOverride All
$ sudo chmod 755 /home/ec2-user/ $ sudo service httpd restart
Step 5: Install PHP5.6 or later
$ sudo yum install -y php56 $ sudo service httpd restart
Step 6: Install MySQL
For step 6, follow the article verbatim.
Step 7: Install WordPress.
$ cd /home/ec2-usr $ wget http://wordpress.org/latest.tar.gz $ tar -xzvf latest.tar.gz
This will uncompress WordPress in its own “wordpress” directory.
$ mv wordpress Sites
Next create the WordPress wp-config.php file:
$ mv wp-config-sample.php wp-config.php
Make appropriate changes on username, database, and password. Then open the broswer to test.
In addition, if you use composer, you’ll need to do the following.
$ cd ~ $ sudo curl -sS https://getcomposer.org/installer | sudo php $ sudo mv composer.phar /usr/local/bin/composer $ sudo ln -s /usr/local/bin/composer /usr/bin/composer
Then you can run
$ sudo composer install
Update your .htaccess in your app root.
Best wishes and happy hacking!