Setting Up WordPress on Amazon EC2 Linux Instance

Step 1: Create an AWS Account

go to and sign up

Step 2: Create an Instance

See my post on Creating a new AWS Instance.

Step 3: SSH into your Instance

From a Unix terminal, use something like,

chmod 600 ~/keyfilename.pem
ssh -i ~/keyfilename.pem

then once connected, i suggest you make sure everything is up to date.

sudo yum update

From a Windows computer you will need to use PuttyKeyGen to generate a PPK file, see HERE
And then use Putty to connect using THESE instructions.
Step 4: Install the Apache Web Server

yum install httpd
service httpd start

// test web server

//add security group rules (

Step 5: Install PHP

Run the following commands to install PHP

yum install php php-mysql
service httpd restart

then create a test file to make sure PHP is installed and working

cd /var/www/html
vi test.php
<?php phpinfo() ?>

goto web site, you should see a php info page

Step 6: Install MySQL

yum install mysql-server

//mysqladmin -uroot create blog


mysql -u root -p
CREATE USER 'wordpress-user'@'localhost' IDENTIFIED BY 'your_strong_password';
CREATE DATABASE `wordpress-db`;
GRANT ALL PRIVILEGES ON `wordpress-db`.* TO "wordpress-user"@"localhost";

Step 7: Install WordPress

cd /var/www/html
tar -xzvf latest.tar.gz
cd wordpress
mv * /var/www/html/


mv wordpress blog
cd blog


mv wp-config-sample.php wp-config.php
vi wp-config.php

change the following lines,

define(‘DB_NAME’, ‘wordpress-db');
define(‘DB_USER’, ‘wordpress-user');
define(‘DB_PASSWORD’, ‘your_strong_password');
define(‘DB_HOST’, ‘localhost’);


define('AUTH_KEY', '<salt_key>');
define('SECURE_AUTH_KEY', '<salt_key>');
define('LOGGED_IN_KEY', '<salt_key>');
define('NONCE_KEY', '<salt_key>');
define('AUTH_SALT', '<salt_key>');
define('SECURE_AUTH_SALT', '<salt_key>');
define('LOGGED_IN_SALT', '<salt_key>');
define('NONCE_SALT', '<salt_key>');

Step 8. allow WordPress to use permalinks

sudo vi /etc/httpd/conf/httpd.conf

<Directory “/var/www/html”>

FROM : AllowOverride None

TO: AllowOverride All

Step 9. fix file permissions for the Apache web server

sudo usermod -a -G www apache
sudo chown -R apache /var/www
sudo chgrp -R www /var/www
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;
sudo service httpd restart

step 10. that the httpd and mysqld services start at every system boot

sudo chkconfig httpd on
sudo chkconfig mysqld on
check they are currently running, if not start them
sudo service httpd status
sudo service mysqld status

Step 11: Map IP Address and Domain Name

See appendix B

Step 12. Run the WordPress installation script


Appendix A. Change your WordPress site URL with the wp-cli

as ec2-user

curl localhost | grep wp-content
curl -O
php wp-cli.phar search-replace 'old_site_url' 'new_site_url' --path=/path/to/wordpress/installation --skip-columns=guid

Appendix B. Get public IP and Map Domain Name to it.

1. Allocate Elastic IP Addresses

2. Registering Domain Names Using Amazon Route 53 (


Appendix D. Connecting to your instance using WinSCP