Install WordPress on Amazon EC2- Part2

This post is the second part of Easily Install WordPress on Amazon EC2. Now I assume you have created your EC2 Micro Instance. Let’s connect with SSH and start installing packages/softwares. We will install Apache, PHP, MySQL, PHPMyAdmin because we need these to run our WordPress.

Note 1: To install any package you need to have root (administrative) privilege but by default you login as ‘ubuntu-$’ a normal user. So you have to make it a super user using ‘sudo su’ command.

Note 2: During installation of any package if it says ‘unable to fetch some archieves’ then you can always use ‘apt-get update‘ command.

Installing Apache, MySQL, PHP and PHPMyAdmin in Amazon EC2 Instance:

Enter this command in your terminal.


This will change user from ‘$’ to ‘#’ (‘$’ indicates a normal user and ‘#’ is used to represent root in Linux). You will need to fire some easy linux commands to install all these packages. General syntax of the command is

]# apt-get install    package_name.

1>     Install Apache on Amazon EC2 Instance run this command in terminal.

]# apt-get install apache2

Once you have installed Apache web server in your instance, look for public DNS of your instance and copy paste it in browsers address bar. You will see something :):

aws public dns

Note: You see some text and it’s because of an ‘index.html’ placed in your web root directory. You will have to delete/remove it in order to display your WordPress page.

2>     Install MySQL on Amazon EC2 run this command in terminal:

]# apt-get  install mysql-server

It will ask you to set root password during installation. Enter a strong root password.


3>     Install PHP5 on Amazon EC2, run this command:

]#apt-get install php5

]#apt-get install libapache2-mod-php5

Now you have to restart the apache webserver with this command:

]# service apache2 restart    


]# /etc/init.d/apache2 restart

Now install php module for MySQL with this command:

]#apt-get install php5-mysql

]#apt-get install libapache2-mod-auth-mysql

4>    Install PHPMyAdmin on Amazon EC2 with this command:

]#apt-get install phpmyadmin


You have to enter password again here, everything is self explanatory on screen so follow the instructions and make sure you remember entered password for future purposes.

Now you will have to install WordPress. To install wordpress first download it from with this command:

Navigate to root directory:

]# cd /var/www

Get WordPress:

]# wget

Now unzip it here. By default WordPress extracts its all files in a ‘wordpress’ folder so you need to move all the files out of that folder and put it in ‘/var/www’. Use these two commands:

Extract Files:

]#tar -xzvf latest.tar.gz

Move files from ‘/var/www/wordpress’ to ‘/var/www’:

]#cp -avr /var/www/wordpress/* /var/www

Note: If you wish you can delete that empty ‘wordpress’ folder and downloaded WordPress file ‘latest.tar.gz’ using rm- f ‘filename’.

Now It’s time to allocate an elastic IP and map it to your created Instance:

Go to your Instance Panel then click Elastic IP then  click Allocate New address:


You will get something like this:


Click on ‘associate address’ and then click ‘yes associate’.  Now go back to your instance panel and have a look at Elastic IP.


Note: If you deallocate your Elastic IP from your Instance and that Elastic IP is not allotted to any instance then you will be charged, check here.

Now you can proceed to install WordPress on your server. First create a database from the PHPMyadmin panel by visiting <your elastic ip>/phpmyadmin.


Proceed with WordPress installation by visiting: <Elastic IP>/index.php. After entering all the information needed for WP installation you will probably get this page:


It says WordPress don’t have permission to write ‘wp-config.php’. So either you copy paste that code manually in the file or allow WordPress by changing permission of the file. Here’s the command for that:

]#  chown -R www-data /var/www

]#  chmod -R 755 www-data /var/www

Now you can easily install your WordPress. But you will not see your default WordPress index page after installation because there’s ‘index.html’ file which needs to be removed so use this command.

]# rm –rf /var/www/index.html.

You will get something like this :):


Share this tutorial with others. Installing Your web application on Amazon servers gives you various advantages. You can install any other application in the same way. Its simply linux commands you need to know. Further you can configure your FTP client to connect with your server for easy file transfer. If you want any application to be deployed on Amazon’s servers do let me know. If I can help you with that.

About sanjeev

Dreamer, Blogger and Thinker. I love to help people in solving their problems. You can also join me HERE

Related posts:

8 Responses so far.

  1. Awesome Tut. Really really helps! I am almost there.

    What would be the default username and password for phpmyadmin. Struggling on that a bit.

  2. Hi sanjeev,

    Thanks for this great tutorial. it worked seamlessly.

    I only have one issue now. Somehow, url rewriting is not not working. Hence, wordpress is not able to use clean urls. any suggestion?

    1. HI Darshak,

      You need to enable rewriting in your apache server.

      Use these two commands in your terminal and your work will be done.

      ]$ sudo a2enmod rewrite

      ]$ sudo service apache2 restart

      Let me know if you still face any issue.

      1. Hi Sanjeev,

        Thanks for that update. I managed to get url rewrite working following the same method you suggested. Although, I had to go via the route of modifying apache config file and enable rewrite module.

        I do have two different question though.

        1. I noticed a warning on AWS console that “In case if your EC2 instance terminates, you will lose your data including wordpress files and data stored by MySql service.”

        Does that mean I should use S3 service for storing data to avoid any accidental data loss? Or my data will remain safe in an EBS volume even if my EC2 instance terminates?

        2. In order to FTP into my wordpress files on EC2 instance, I followed the procedure published on AWS support. It provided me access to my user’s home directory and www root. Hence, I had to create a soft link pointing to www root in my home folder. I am able to access www root now. However, it is not letting me update any file via FTP. It throws an error saying your user ‘ubuntu’ does not have access. Can you suggest a way out?

        1. Hello Darshak,

          1) yes if you terminate ec2 instance you will loose all your data so better use s3 (for backup).

          2) As even when you connect via FTP you are connected as ubuntu user. So you need to change the user ownership using chown command. go to terminal and fire this command.

          ]$ sudo chown -R ubuntu /var/www

          Let me know if this solves your problem. else you can further use chmod to change folder permissions.

Comments are closed.