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.
-$ SUDO SU
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 :):
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 wordpress.org with this command:
Navigate to root directory:
]# cd /var/www
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:
]#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.