Warning: count(): Parameter must be an array or an object that implements Countable in /home/cloudbro/public_html/wp-includes/post-template.php on line 284

Launching WordPress on the Global Cloud Marketplace | Part 1


By now, cloud-based systems have proven their superiority over traditional infrastructure: Cloud infrastructure facilitates seamless availability (touting almost zero downtime), scalability, security, and more (You can read more about cloud based systems on our blog). As of January 2015, WordPress was used by more than 23% of top 10 million websites and it’s still the most popular blogging system on the web with more than 60 million websites.

Considering the worldwide popularity and rapid adoption rates of WordPress and the cloud, more and more people are interested in integrating the two. That’s where we come in with this series of tutorials for deploying WordPress on the cloud. This series will consist of articles and tutorials covering a range of topics such as installing, deploying, scaling, tuning, and monitoring WordPress sites using cloud infrastructure.

In this first article, we will cover WordPress installation on a single cloud instance. As we move forward in the series, we will see how to optimize performance of our instance and then scale it on demand (A very important cloud feature!).

WordPress & Cloud

Similar to most of the legacy web applications, WordPress was not built keeping cloud in mind. So deployment of a WordPress site on cloud servers differs from the usual VPS deployment, with the main difference being that cloud systems assume ephemeral filesystem. This means all the updates and changes you make live and die with that particular instance. In the case of WordPress on cloud systems, one cannot perform operations from the admin panel that would affect the filesystem (for example: uploading images, updating themes and plugins, etc.). To overcome these issues we can leverage volume storage and a global deployment strategy, which we will discuss in future articles.

Getting Started

First let’s see how to get WordPress up and running on cloud (single instance). There are two ways to approach this:

1. Use a virtual machine and install stack for WordPress manually
2. Directly make use of the image with WordPress pre-installed

We’ll look into both methods. Before moving forward, you’ll need to create free account on computenext.com (you get $10 credit for signing up!). Fill all the required details to get started.

The second method is quite straightforward–the complete process is shown in GIF below. if you don’t have any particular preference about OS, location, or image provider, then this is the perfect choice for you. Once your account is activated, just click here.

Personally, I prefer the first method as I get to choose and customize the system according to my requirements. One can choose between several providers, OSs, prices, locations, etc. To use VM, click here and follow the same procedure as we did for WordPress instance.

Note that we will be using ubuntu 12.04 LTS for this tutorial. Once your VM is activated, grab the credentials and ssh into the server so you can take care of the AMP part in LAMP stack.

[code language=”bash”]$ ssh [email protected]_ip[/code]

Or if you are given with a keyfile

[code language=”bash”]$ ssh -i path_to_keyfile/keyfile [email protected]_ip[/code]

Change the root password

[code language=”bash”]$ passwd[/code]

Add new user, so you don’t have to use root

[code language=”bash”]$ adduser wpuser[/code]

Give root privileges to the new user

[code language=”bash”]$ visudo[/code]

This will open sudo configuration, find root ALL=(ALL:ALL) ALL and add following code below that line.

[code language=”conf”]wpuser ALL=(ALL:ALL) ALL[/code]

Configure ssh for new user

[code language=”bash”]$ nano /etc/ssh/sshd_config[/code]

Update sshd_config

[code language=”conf”]PermitRootLogin no
AllowUsers wpuser[/code]

Reload ssh to make sure changes are implemented

[code language=”bash”]$ reload ssh[/code]

Login using new username i.e. wpuser and pass. Note that all the processes after you ssh are valid for any instance you are working on, be it local or remote.

[code language=”bash”]$ ssh [email protected]_ip
$ sudo apt-get update
$ sudo apt-get install apache2[/code]

After installing apache, visit localhost (or the ip dedicated to this instance). You should see an “It works!” page.

Now it’s time to install MySQL
[code language=”bash”]$ sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
$ sudo mysql_install_db
$ sudo /usr/bin/mysql_secure_installation[/code]

Let’s now install php

[code language=”bash”]$ sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt[/code]

To make sure php files are served, we need to add php to directory index

[code language=”bash”]$ sudo nano /etc/apache2/mods-enabled/dir.conf[/code]

Update the configuration as shown below

[code language=”conf”]DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm[/code]

Now let’s check if our LAMP stack is working properly. Create test php file

[code language=”bash”]$ sudo nano /var/www/test.php[/code]

Add following code between php tags in test.php

[code language=”php”]phpinfo();[/code]

Restart apache so that all the changes are implemented

[code language=”bash”]$ sudo service apache2 restart[/code]

Visit http://server_ip/test.php or localhost/test.php. You should see the following:

Now let’s download and extract files necessary for installing WordPress

[code language=”bash”]$ wget http://wordpress.org/latest.tar.gz
$ tar -xzvf latest.tar.gz[/code]

Create database for WordPress

[code language=”bash”]$ mysql -u root -p[/code] [code language=”sql”]> CREATE DATABASE wordpress_production;
> CREATE USER [email protected];
> SET PASSWORD FOR [email protected]= PASSWORD(“wppassword”);
> GRANT ALL PRIVILEGES ON wordpress_production.* TO [email protected] IDENTIFIED BY ‘wppassword’;
> exit[/code]

Our production database is ready for use! Note that you can use separate instance for database if you want to.

[code language=”bash”]$ cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php[/code]

We need to add MySQL credentials to wp-config.php, so that WordPress can connect to production database.

[code language=”bash”]$ sudo nano ~/wordpress/wp-config.php[/code]

Move all the WordPress files to /var/www

[code language=”bash”]$ sudo rsync -avP ~/wordpress/ /var/www/
$ cd /var/www/
$ sudo chown www-data:www-data /var/www -R
$ sudo chmod g+w /var/www -R[/code]

That’s it!, visit http://server_ip/wp-admin. You should see a form asking you to fill admin details. Complete this process and your WordPress site is ready for the world to see!

What’s next ?

We just got WordPress up and running on our cloud instance! In the next articles we’ll be able to see the differences between cloud servers and VPS. We will see how to add assets to your WordPress website, enhance the performance of your website and more.

Stay tuned and if you have any questions, ask them in the comments below!

Start typing and press Enter to search