I found Christophe Coenraets’s blog about Setting Up WordPress on Amazon EC2 in 5 minutes and inspired by that decided to setup a WordPress blog of my own that would reside in the Amazon cloud running on the Ubuntu virtual server instance. Here is also useful information on how to install WordPress.
To be honest, it took much longer than 5 minutes – actually several hours – to get the site up-and-running, as I encountered several smaller problems that had to be solved. I tried to document all the steps required to setup this site. Hope you find these instructions useful! If so, please comment on this article!
1. Create an AWS account
To my surprise, Amazon offers a Free Usage Tier that can be used for anything you want to run in the cloud: launch new applications, test existing applications etc. After reading the “small print”, I realized that this setup is free only 12 months following your AWS sign-up date, and after that you pay standard, pay-as-you-go service rates. So with this setup, monthly cost should be $15/month after the initial 12 months.
You can sign up here and you can also use your existing Amazon ID. As a part of the online registration process, you’ll have to provide a credit card and a phone number where you will be called for verification purposes.
2. Create Ubuntu virtual server instance
To start using the Amazon Elastic Cloud EC2, you need to launch a virtual server, known as an Amazon EC2 instance.
Login to AWS, and from the EC2 Dashboard click on the “Launch Instance” button, choose the “Classic Wizard” and use the following options:
- I chose Ubuntu 11.10 (64 bit) and clicked on the “Next”
- Instance Type: T1 Micro. This is free!
- Create a new key pair (e.g. mikkor.pem) and download it for example to your home directory. Do not share this file as it gives a full access to your server instance!
- Select the quick start security group.
- Launch your instance.
3. Create an elastic IP to access your virtual server
Elastic IP addresses are static IP addresses designed for dynamic cloud computing. An Elastic IP address is associated with your account, not a particular instance, and you can map your public IP addresses to any EC2 instance associated with your account.
From the EC2 Dashboard, select “Elastic IPs”
- Click on the “Allocate New Address”
- And “Associate Address” with the newly created EC2 instance
- Write down the Elastic IP Address just created because you will need it in the next phase.
4. SSH into your account
The default user is “ubuntu”, so to ssh your account, use the following shell command on your local computer. In Windows environment, you may want to use the Putty client.
ssh ubuntu@; -i
ssh firstname.lastname@example.org -i mikkor.pem
If you get a message about your .pem file permissions being too open, chmod your .pem file as follows:
chmod 600 ~/mikkor.pem
Many of the shell commands below require a root access. To avoid having to prefix these commands with “sudo”, switch to superuser:
5. Install Apache Web server
In Ubuntu, you need to use AptGet package management tool to install additional modules. So, before installing Apache, I had to run the following AptGet maintenance commands (skip “sudo” if you are logged in as root):
sudo apt-get update - updates source lists
sudo apt-get upgrade - upgrades all installed packages.
Then, install the Apache web server package:
sudo apt-get install apache2
Restart Apache using the following command:
sudo apache2ctl restart
Check that Apache started working using the recently created elastic IP or public DSN name that you can find from the AWS Management console by selecting the instance you just created, see the image below.
So in this example, using your Web browser, go to:
http://126.96.36.199/ OR http://ec2-46-51-157-210.eu-west-1.compute.amazonaws.com
You should see the page with the following text:
This is the default web page for this server.
The web server software is running but no content has been added, yet.
6. Install MySQL and create the database
Get the MySQL package:
sudo apt-get install mysql-server
Create your “wordpress” database:
mysqladmin -uroot create wordpress
Secure your database:
Answer the wizard questions as follows:
- Enter current password for root: Press return for none
- Change Root Password: N
- Remove anonymous user: Y
- Disallow root login remotely: Y
- Remove test database and access to it: Y
- Reload privilege tables now: Y
Following Jonathan Moeller’s instructions I setup MySQL for use with WordPress. WordPress requires a database and a database user with full permissions to access its database. To start the MySQL command-line client, use this command:
mysql -u root
If you have specified a password for the mysql root, use command:
mysql -u root -p
Enter the password for the MySQL root user, and you’ll see a MySQL command prompt, which will look like this:
WordPress database/schema was already created earlier, so now you need to create a user to access that database, and grant our new user all rights to the WordPress database.
CREATE USER wordpressuser;
Create the password for the wordpressuser:
SET PASSWORD FOR wordpressuser= PASSWORD(“1234”);
Assign all privileges on the “wordpress” database to the “wordpressuser” user. Use this command to assign the permissions:
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser IDENTIFIED BY ‘1234′;
Once you are done, use this command to quit the MySQL command-line interface:
7. Install Php
Install all the required PHP packages
sudo apt-get install php5 php5-mysql php5-gd
… and restart Apache
7. Install WordPress
Get the latest wordpress sources:
Use this command to unpack the WordPress files to your home directory /home/ubuntu/ (user: ubuntu):
tar -xzvf latest.tar.gz
Make a directory in /var/www for the WordPress files:
Finally, copy the WordPress files over to the /var/www/wordpress directory from ubuntu user’s home directory (/home/ubuntu)
cp -r ~/wordpress/* /var/www/wordpress
8. Configure WordPress
Go to WordPress installation directory:
Create the WordPress wp-config.php file by copying the sample file:
cp wp-config-sample.php wp-config.php
Start editing wp-config.php file with the nano editor:
Configure wp-config.php as follows
/** MySQL database name*/
/** MySQL database username */
/** MySQL database password */
/** Add this line: sets up direct method for wordpress, auto-update without ftp **/
In the wp-content directory (/var/www/wordpress/wp-content), create the following sub-directories for the uploads and plugin upgrades
Change owner to “www-data” that is the Apache user
chown www-data plugins upgrade uploads
After these changes, “wp-content” should have the following sub-folders and access rights:
drwxr-xr-x 6 root root 4096 2013-01-19 20:20 .
drwxr-xr-x 5 root root 4096 2013-01-21 21:34 ..
-rw-r--r-- 1 root root 28 2013-01-17 09:52 index.php
drwxr-xr-x 9 www-data root 4096 2013-01-21 21:56 plugins
drwxr-xr-x 4 root root 4096 2013-01-17 09:52 themes
drwxr-xr-x 3 www-data root 4096 2013-01-23 07:27 upgrade
drwxr-xr-x 3 www-data root 4096 2013-01-19 20:19 uploads
Just in case, load new settings to Apache
service apache2 reload
9. Map IP Address and Domain Name, and configure Apache
To have a nice URL like (http://rusama.net) for your blog, you need to buy and map your domain name to the elastic IP address just recently created.
My DNS provider is Go Daddy and there it was relative simple to configure DNS using these instructions.
To configure apache so that http://rusama.net immediately shows the blog, I had to create /etc/apache2/sites-available/wordpress file as follows:
Options Indexes FollowSymLinks MultiViews
allow from all
After this, I had to enable this site by a command:
The previous command creates a symlink to the sites_enabled folder pointing to the wordpress configuration file.
Reload Apache’s new settings:
service apache2 reload
10. Finalize WordPress installation
Finalize WordPress installation using the Web browser, go to the newly created page:
This should trigger the WordPress configuration process. At least configure URLs, e.g.
Also, I recommend changing permalink settings as follows:
WordPress permalink settings
To save the permalink settings automatically, you need to create .htaccess file to the wordpress installation root folder (/var/www/wordpress) with the following access rights (use chown www-data .htaccess and chmod 755 .htaccess commands):
-rw-r--r-- 1 www-data root 637 2013-01-24 11:14 .htaccess