Ok, if you’ve been following this series you should have an EC2 instance up and running, but not serving up squat. Today we’ll get WordPress up and running. The main steps are:

  1. Apache
  2. WordPress
  3. MySql
  4. Security

Thankfully, none of these are going to be the deal-breaker! :-D

First off, let’s deal with Apache.

The way things are installed by default would be bad for Apache — it’s default assumes a lot more memory than you get with a micro instance.

So, let’s edit the configuration:

sudo nano /etc/httpd/conf/httpd.conf

The only thing I’ve changed is the bit that looks like this:

<IfModule prefork.c>
  StartServers 5
  MinSpareServers 5
  MaxSpareServers 5
  ServerLimit 5
  MaxClients 5
  MaxRequestsPerChild 4000

This is around 10% down through the file. What we’re doing is setting the maximum number of web server processes. Five is enough for most small sites.

Next, we need to configure a web sites. Most of the way down the file just un-comment the following line:

NameVirtualHost *:80

This will inform that you’ll be hosting multiple web sites. Now, I don’t really know that you will be, but there’s little problem to do this now.

Next, you’ll want to create a file to configure your site. I’m going to call it www.site.com, but please configure it to be whatever you need it to be! Save the file, then:

sudo nano /etc/httpd/conf.d/www.site.com.conf

Type this into that file and save:

<VirtualHost *:80>
  ServerName www.site.com
  DocumentRoot /var/www/www.site.com

    Options FollowSymLinks
    Allow from all
    AllowOverride all

This will get apache serving up that directory with that URL.

Next, we need MySql up and running.

First, let’s create a password for root…

mysqladmin -u root password some-password


mysql -u root
CREATE SCHEMA `WordpressDatabaseName`;
CREATE USER 'WPDBUser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON WordPressDatabaseName.* to 'WPDBUser'@'localhost';

This will make a new database in MySql, a new user, and grant that new user access to the database.

Finally, let’s configure MySql for a small memory footprint:

sudo cp /usr/share/mysql/my-small.cnf /etc/my.cnf

Next, let’s set up both Apache and MySql to start by default:

sudo /sbin/chkconfig --levels 235 httpd on
sudo /sbin/chkconfig --levels 235 mysqld on


At this point we’re just about ready to install WordPress!

cd ~
wget http://wordpress.org/latest.zip unzip latest.zip
sudo cp -R wordpress /var/www/www.site.com
sudo chmod -R apache /var/www/www.site.com

Things are just about ready to go now!

Last, we need to set up security in EC2. In the EC2 dashboard, go to the security section. From there, select the security group that you picked for your instance and add HTTP (port 80) to it.

While you’re at it, configure an elastic IP and point it at the instance as well.

Once you have that done, start up MySql and Apache.

sudo /etc/init.d/mysqld start
sudo /etc/init.d/httpd start

From here you should be able to go to your IP address in a web browser and follow along with the questions WordPress will have for you.

Congrats! You have a blog!