Steps to setup a WordPress blog on the Amazon EC2 infrastructure.
Are you looking to start a WordPress blog? Amazon EC2 provides a cloud infrastructure where you can host your blog. In this tutorial, we will walk through the steps to set up a WordPress blog on Amazon EC2.
Prerequisites Before we start, you will need the following:
- Putty and PuttyGen installed on Windows (or ready for use)
- Basic understanding of Linux concepts and commands. Know how to use Putty and optionally understand security concepts.
- An Amazon AWS account. A credit card signup is required even though the basic Linux instance (micro instance) is free for 12-months.
Part A — Setting up the EC2 Instance
- Login to the Amazon AWS console and select EC2 — Virtual servers in the cloud.
- Under Create Instance, click on Launch Instance.
- Select Amazon AMI Linux — 64 bit.
- Check the settings and maintain defaults. Keep clicking next until you reach the Configure Security Group section.
- Click Add Rule twice — once for the HTTP (port 80) and another for the HTTPS (port 443). The SSH rule is already added with port 22.
- Click Review and Launch, then Launch. This opens a dialog to create a new key pair.
- Create a new key pair and download the PEM file to your local folder.
- Now click Launch Instance and wait for 5 mins for startup.
- In the meantime, convert the PEM file to PPK file using PuttyGen tool.
Part B — Allocating and Associating an Elastic IP Address
- Once the instance has launched, go to the EC2 Dashboard, click Elastic IPs and allocate a new address.
- Right-click on the allocated Elastic IP and associate it with the running instance (some 10-character code). Click Associate.
- Go back to EC2 Dashboard and check the Public IP and Elastic IP — both should be the same.
- Copy the IP address, open Putty, and paste the IP address into Putty’s Host.
- Go to SSH->Auth, browse and open the converted PPK file. Then click Open. Putty’s black screen should open up.
- For Windows, login as ec2-user. For Mac, run the command “ssh -i keyfile.pem ec2-user@11.22.33.44”.
Part C — Installing WordPress on the EC2 Instance
- Once you’ve logged in as the ec2-user, type in the below commands one after another.
- sudo yum update — Updates all software patches on the instance.
- sudo su — Switching to root user.
- yum install httpd — Installs Apache server.
- service httpd start — Starts Apache server.
- yum install php php-mysql — Installs PHP.
- yum install mysql-server — Installs MySQL.
- service mysqld start — Starts MySQL server.
- mysqladmin -uroot create myblog — myblog will be the name of the database in this example).
- mysql_secure_installation — Follow these steps for securing mysql:
- Enter current password for root: just press enter key.
- Set root password?: Y (enter password twice).
- Remove Anonymous Users?: Y.
- Disallow root login remotely: Y.
- Remove test database and access to it?: Y.
- Reload privileges table now?: Y.
11. cd /var/www/html — Go to this directory.
12. wget http://wordpress.org/latest.tar.gz — Download the latest version of WordPress.
13. tar -xzvf latest.tar.gz — Extract WordPress.
14. mv wordpress myblog — Rename the blog to myblog.
15. cd myblog — Go to the myblog directory.
16. mv wp-config-sample.php wp-config.php — Rename the PHP config file.
17. vi wp-config.php Edit the wp-config.php file
with the given information :
define('DB_NAME', 'myblog')
define('DB_USER', 'root')
define('DB_PASSWORD', 'yourpassword')
service httpd restart Restarts Apache server
Note: In all the “install” commands, press “y” if the shell asks for install confirmation. Now, open your browser, and enter : http://<ip_adddress>/myblog