This article is a continuation of what has been discussed here.
Nowadays, pretty much anybody can have their own site which can be used for blogging, for selling something or for anything else we can think of.
The number of people who have chosen to blog has increased spectacularly.
Before, those who wanted to have a website (not particularly a blog) would have needed to either contact someone who had web programming knowledge, or learn web programming themselves.
However, those who want to blog do not need a complex product. Basically, a blogging tool should be simple enough so that you don’t need to be a computer expert to deploy it.
The increasing number of people starting their own websites has led to the creation of open source tools that will simplify the process of getting a website online.
The most popular of these is WordPress. Due to the widespread use of this platform, it’s very likely that before you landed on this website to read this article, you’ve already visited a website that uses WordPress.
This article will show you how you can have a server running WordPress in minutes using Amazon Web Services (AWS).
To illustrate how simple it is, I will first show you how to do it manually on a Linux server.
As you probably just figured out, you will need Linux skills to do so. The only other requirement is that you have a server with Linux on it. It can be any server, physical or virtual.
For the purpose of this article, let’s assume that we just finished practising what we’ve learned in the article Translating your Windows/Linux Server Skills for the Cloud: How to deploy a server in Amazon AWS. You now have an empty Linux server in AWS and you can do whatever you want with it.
First you need to install the Apache web server:
[ec2-user@ip-172-31-43-166 ~]$ sudo yum install httpd
Start the Apache web server:
[ec2-user@ip-172-31-43-166 ~]$ sudo service httpd start Starting httpd: [ OK ] [ec2-user@ip-172-31-43-166 ~]$
Then install PHP:
[ec2-user@ip-172-31-43-166 ~]$ sudo yum install php php-mysql
Restart the Apache web server:
[ec2-user@ip-172-31-43-166 ~]$ sudo service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] [ec2-user@ip-172-31-43-166 ~]$
Install MySQL and start the mysql daemon:
[ec2-user@ip-172-31-43-166 ~]$ sudo yum install mysql-server [ec2-user@ip-172-31-43-166 ~]$ sudo service mysqld start Initializing MySQL database: Installing MySQL system tables... OK Filling help tables... OK [ OK ] Starting mysqld: [ OK ]
Create the database used for WordPress:
[ec2-user@ip-172-31-43-166 ~]$ sudo mysqladmin -uroot create WP [ec2-user@ip-172-31-43-166 ~]$
Use this command to set the root password for MySQL. In my case, the password is ‘password’, without the single quotes.
[ec2-user@ip-172-31-43-166 ~]$ sudo /usr/bin/mysqladmin -u root password password
Now we can proceed with the actual WordPress installation.
Go to /var/www/html, download the latest WordPress package and decompress it:
[ec2-user@ip-172-31-43-166 ~]$ cd /var/www/html [ec2-user@ip-172-31-43-166 html]$ pwd /var/www/html [ec2-user@ip-172-31-43-166 html]$ sudo wget http://wordpress.org/latest.tar.gz --2014-06-05 14:43:39-- http://wordpress.org/latest.tar.gz Resolving wordpress.org (wordpress.org)... 184.108.40.206, 220.127.116.11 Connecting to wordpress.org (wordpress.org)|18.104.22.168|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 5812042 (5.5M) [application/octet-stream] Saving to: âlatest.tar.gzâ 100%[=======================================================================================================================================>] 5,812,042 1.87MB/s in 3.0s 2014-06-05 14:43:42 (1.87 MB/s) - âlatest.tar.gzâ saved [5812042/5812042] [ec2-user@ip-172-31-43-166 html]$ sudo tar -xzvf latest.tar.gz wordpress/
Rename the ‘wordpress’ folder to match the database name we created earlier (this is not mandatory, but helps you have consistent naming) and then go to that folder:
[ec2-user@ip-172-31-43-166 html]$ sudo mv wordpress/ WP [ec2-user@ip-172-31-43-166 html]$ ls latest.tar.gz WP [ec2-user@ip-172-31-43-166 html]$ [ec2-user@ip-172-31-43-166 html]$ cd WP/ [ec2-user@ip-172-31-43-166 WP]$
Create the wp-config.php file by using the default sample. Edit it to reflect the database created earlier and to provide the username and password used to connect to the database:
[ec2-user@ip-172-31-43-166 WP]$ sudo mv wp-config-sample.php wp-config.php
Edit the wp-config.php:
[ec2-user@ip-172-31-43-166 WP]$ sudo vim wp-config.php
These lines should look similar:
[ec2-user@ip-172-31-43-166 WP]$ cat wp-config.php | grep DB define('DB_NAME', 'WP'); define('DB_USER', 'root'); define('DB_PASSWORD', 'password'); define('DB_HOST', 'localhost'); define('DB_CHARSET', 'utf8'); define('DB_COLLATE', ''); [ec2-user@ip-172-31-43-166 WP]$
Once this is done, you can access your blog by typing in the browser bar something like: http:///WP
In my case, since the server is on AWS, there is a specific naming used as you might recall. I would have to access this link to start the WordPress configuration:
Once you access the link, the WordPress configuration process will kick off:
And that’s it. I created a post for testing purposes and you can try to access it: http://ec2-54-86-228-9.compute-1.amazonaws.com/WP/
As you can see, this might be a little bit too hard for someone who doesn’t have Linux skills. Also, even if you have such skills, if you don’t know what you are doing, you won’t be able to complete it without the exact steps.
Now I would like to show you how you can deploy WordPress in AWS using a template.
AWS provides its customers standard templates to deploy some of the most used web applications in only a few steps. One of these is WordPress.
From the AWS console, click on CloudFormation:
Click on ‘Create Stack’ and then name as suggestive as possible and from Source, choose WordPress Blog and then click on ‘Next’:
Then choose the database root password of your choice and click on ‘Next’:
Use a key/value to tag this resource and click on ‘Next’:
Click on ‘Next’ to review:
After you click on ‘Create’ you will get a list with all the stacks. The one that we created will have the status of ‘CREATE_IN_PROGRESS’:
It will take around five minutes before you can use this resource. Once you see the status ‘CREATE_COMPLETE’, go to the ‘Outputs’ tab to get the link which can be used to access your WordPress deployment:
The link that I need to access to start the WordPress configuration process is:
Once you enter this link in your browser, you will be redirected to a page where the initial configuration of WordPress is being done:
From this point on, everything is the same as with the manual installation of WordPress. Configure a user which will be used to log in so that you can create new posts.
As you can see, installing WordPress in AWS is much simpler and less error prone than installing it on a server of your own. All you need to deploy such services is to get an AWS account.