This is a small recipe to convert your ec2 microinstance (free for a year) to hold your wordpress blog.

The main ingredients are:

  • EC2 Microinstance
  • nginx
  • nginx with php-fpm
  • Wordpress
  • PDO for wordpress (to use SQLite as database engine)

Creating and setting up the EC2 microinstance

Just signup in AWS (Amazon Web Services) and create a EC2 microinstance (free tier). If you found in troubles follow this guide but remember to not install the Apache http server! we are going to use nginx :)

Installing Nginx

The nginx team has created a script to make easy to install nginx on EC2. on this page you will found the script description. Basically are this three commands.

sudo bash  #become root  
bash ./

Configuring Nginx to execute php

To execute php we will use the php-fpm (a php daemon that executate the php files and have a better performance)

yum install  php-fpm php-xml php-pdo php-odbc 
  php-soap php-common php-cli php-mbstring php-bcmath php-ldap  
  php-imap php-gd php-pecl-apc

Configure php-fpm editing the /etc/php-fpm.conf and /etc/php-fpm.d/www.conf

emergency_restart_threshold = 10  
emergency\_restart\_interval = 1  
process\_control\_timeout = 15s
listen = /dev/shm/php-fpm-www.sock  
listen.allowed_clients =  
listen.owner = nginx = nginx  
listen.mode = 0664

user = nginx  
group = nginx

pm = static;  
pm.max_children =1

php\_admin\_value[memory_limit] = 64M

Now, add this location to the  /etc/nginx/nginx.conf file or to your  virtual server.

               location ~ .php$ {  
                        fastcgi_pass   unix:/dev/shm/php-fpm-www.sock;
                        fastcgi_index  index.php;
                        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                        include        fastcgi_params;

Finally start the services

service php-fpm start
service nginx start

 Installing wordpress

Download the latest version of wordpress on your /var/www folder and uncompress.

cd /var/www  
tar zxf latest.tar.gz

Configure PDO for Wordpress

PDO for wordpress is an abstraction of the database code of wordpress so we can avoid installing mysql that is really resource intensive.

Just download from here and uncompress inside the wp-content folder inside wordpress, make sure that you have this folder setup /var/www/wordpress/wp-content/pdo, also you must have write permissions in the wordpress folder.

chown -R nginx:nginx /var/www/wordpress

Also copy the wp-config-sample.php to wp-config.php and add the following lines

define(‘DB_COLLATE’, ”);  
define(‘DB_TYPE’, ‘sqlite’); // use sqlite


 Enjoy your blog

Now just install like a normal wordpress by accessing to your ec2 public dns name and follow the installation steps.

For a better performance I use the SuperCache plugins for wordpress, but feel free to use any other that avoids access to the database.