This is a real quick guide to setup WordPress On Amazon EC2. It is a direct result of following a Youtube tutorial on the same subject by a guy named Avishai Sam Bitton, who is the Marketing Director at Imonomy & Founder of Go Social.
The Youtube tutorial by itself was great. In 10 minutes, Avishai shows you how to go from creating a Linux instance to the WordPress admin page. It is done on the Amazon Linux AMI (not Ubuntu or RHEL). The only missing thing is the Linux commands cheat sheet (copy-paste-able) which I will cover in the following paragraphs. I will try to provide maximum information in minimal words.
Here is the actual video and what follows is my notes on the same :
To setup a WordPress blog on the Amazon EC2 infrastructure, you need to know and do the following as a prerequisite:
Now, open your browser, and enter : http://IPAddress/myblog (in our case, http://11.22.33.44/myblog).
Your Wordpress blog's Admin installation page should be ready for configuration.
If your web server is running on port 8080, then use the url : http://11.22.33.44:8080/myblog.
The Youtube tutorial by itself was great. In 10 minutes, Avishai shows you how to go from creating a Linux instance to the WordPress admin page. It is done on the Amazon Linux AMI (not Ubuntu or RHEL). The only missing thing is the Linux commands cheat sheet (copy-paste-able) which I will cover in the following paragraphs. I will try to provide maximum information in minimal words.
Here is the actual video and what follows is my notes on the same :
To setup a WordPress blog on the Amazon EC2 infrastructure, you need to know and do the following as a prerequisite:
- Have Putty and PuttyGen installed (or ready for use)
- Have basic understanding of Linux concepts and commands. Know how to use putty, and optionally understand security concepts.
- You should have created 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
- Login to the Amazon AWS console.
- Select : EC2 - Virtual servers in the cloud.
- Under Create Instance, click on Launch Instance.
- Select Amazon AMI Linux - 64 bit
- Check settings. Maintain defaults. Keep clicking next - until you reach the Configure Security Group section.
- Click Add Rule twice :
- One for the HTTP (port 80)
- another for the HTTPS (port 443).
- Also add a third one and select Custom TCP port. Enter port 8080 (if your apache or nginx server runs on this port)
- The SSH rule is already added with port 22.
- Click Review and Launch. Click Launch. This opens a dialog to create a new key pair.
- Create a new key pair. Download the pem file to your local folder.
- Now click Launch Instance (wait for 5 mins for startup)
- In the meantime, convert the pem file to ppk file.
- Windows : PuttyGen tool, go to Menu->Convert->Import->Save file with ppk extension to your local drive.
- If you are on Mac, no need to convert. You can use the pem file to login directly using the generated Elastic IP address (steps given below).
Part B
- The instance which you launched couple of steps back should now be running(green tick mark)
- On the Left pane -> click Elastic IPs -> Allocate New Address -> Yes,Allocate
- Right click on the allocated Elastic IP -> Associate Address -> running instance (some 10-character code). Click Associate.
- Go to EC2 Dashboard -> Running Instances. Check the Public IP and Elastic IP (both should be same).
- Copy the IP address. Open Putty and copy the IP address (say 11.22.33.44) into putty's Host.
- Go to SSH->Auth, browse open the converted ppk file. Go back to Session and click Open. Putty's black screen should open up.
- Windows : Login as : ec2-user
- Mac : ssh -i keyfile.pem ec2-user@11.22.33.44
Part C - The Linux Commands (aka Cheat Sheet)
Once you've logged in as the ec2-user, type in the below commands one after another.
Note: In all the "install" commands, press "y" if the shell asks for install confirmation.
Note: In all the "install" commands, press "y" if the shell asks for install confirmation.
Commands | Notes |
---|---|
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 the name of the database in this example) |
mysql_secure_installation | Follow these steps: * 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 |
cd /var/www/html | Go to this directory |
wget http://wordpress.org/latest.tar.gz | Download the latest version of Wordpress |
tar -xzvf latest.tar.gz | Extract Wordpress |
mv wordpress myblog | Rename the the blog to myblog |
cd myblog | Go to the myblog directory |
mv wp-config-sample.php wp-config.php | Rename the php config file. |
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') * press escape key * :wq! (to save and exit) |
service httpd restart | Restarts Apache server |
Now, open your browser, and enter : http://IPAddress
If your web server is running on port 8080, then use the url : http://11.22.33.44:8080/myblog.