Hosting a Website on the Rapid Access Cloud

cloud-network-image-7

Introduction

The Rapid Access Cloud provides immediate access to computing resources which can be used to render 3D graphics, analyze data, and prototype applications. It gives users a platform for developmental work (non-production environments), and can also help to showcase their work on a website set up within the cloud environment. This document will explain how.

Before You Begin

Make sure you have read our Basic Guide to learn how to get up and running on the Rapid Access Cloud. You will need to know how to create a key pair, security group, and instances, and how to allocate a Floating IP to your instance.

To follow along with the instructions below, make sure you have done the following:

  1. Created a SSH Key Pair.
  2. Configured a security group to allow all traffic on ports 80, 443, and 4000.
  3. Launched an Ubuntu 14.04 instance. The name of the instance or the type of flavor does not matter.
  4. Associated a Floating IP to your instance.

Hosting a Jekyll Site

Jekyll is a static website generator. In short, it enables you to create articles and blog posts in plain text, and compiles that text into a full website. It's entirely possible to install Jekyll onto your local workstation, but to make instructions easier, this document will describe how to install it on the Ubuntu 14.04 instance you created.

To begin, log in to your instance via SSH through a command prompt:

 $ ssh -i /path/to/key ubuntu@<floating-ip>

Once logged in, configure the instance to use Cybera's local "apt" proxy. This will make software packages download and install much quicker:

$ /usr/local/bin/localSUS
$ sudo apt-get update

Jekyll has a few prerequisite pieces of software. To install them, run:

$ sudo apt-get install -y ruby2.0 ruby2.0-dev make

Next, install Jekyll:

$ sudo gem2.0 install jekyll

When this command finishes, Jekyll will be installed.

You can create a new Jekyll-based website by doing the following:

$ jekyll new mysite
$ cd mysite
$ jekyll serve -H 0.0.0.0

Now open a browser and visit http://<floating-ip>:4000.

Running a website via "jekyll serve" is not practical. Instead, it's better to install an actual web server, like Apache, and serve the site through it. To do this, first install Apache:

$ sudo apt-get install apache2

Next, compile your Jekyll site into a set of static HTML files. Ensure you are still in the "mysite" directory and run:

$ jekyll build

The result will be a set of static HTML files in the "_site" directory. Copy these files to the "/var/www/html" directory by doing the following:

$ sudo cp -a _site/* /var/www/html/

Now visit the following address in your browser: http://<floating-ip>

And now you have a Jekyll-based site set up on an Apache server.

This only scratches the surface with Jekyll. To learn more about how to create posts and articles, check out its documentation here.

Using a Domain Name

Accessing your site via http://<floating-ip> works, but it's not very convenient to type. Instead, consider using a domain name.

If you don't have a domain name, you can purchase one from a wide variety of vendors (also known as registrars in the domain name world). GoDaddy, Namecheap, and EasyDNS are all reputable domain registrars. They also have the added benefit of providing a DNS solution, the importance of which will be explained now.

Once you have a domain name, you need to connect the domain to your Floating IP. This is done through the Domain Name System (DNS). For ease of use, it's recommended to use the DNS service provided by your domain registrar. For this document, we'll use Namecheap.

Log into your Namecheap account and go to your Dashboard. Find your domain in the dropdown list and click the Manage button:

Next, click on the Advanced DNS tab. You'll see a screen similar to this:

The first thing to do is to change the "parkingpage.namecheap.com." value to match your domain name. In the above example, "parkingpage.namecheap.com." is changed to "rapid-access.cloud." Don't forget the "." at the end.

You can also delete the "URL Redirect Record".

Next, click on the "Add New Record" button. Choose "A Record" for the type, use "@" for the host, and use your Floating IP for the IP address. The end result will look similar to the this (the Floating IP is not shown):

Once these changes are in place on the dashboard, they must still propagate throughout the internet. This could take a few hours. You can check on the status in two different ways:

Enter http://your-domain.com in a browser. If you see your Jekyll site, then the changes are in effect.

Run "dig your-domain.com" on a command prompt and wait until you see your Floating IP as the result.

Hosting a WordPress Site

Jekyll is a quick and easy way to get a website up and running, but it does have limitations. For example, it might not be practical to have everyone log in to your instance via SSH and create articles and blog posts on the command line.

Another option to host a website is to use WordPress. WordPress is a popular and powerful free content management system. Setting it up is a little more involved than Jekyll; we'll lay out the steps here.

First, WordPress requires a MySQL database to store the site content. You can install MySQL on your instance by entering the following:

$ sudo apt-get install mysql-server

You will be prompted to enter an administrator password during the install. Choose a secure password.

Once MySQL is installed, you will need to create a database and user for WordPress. Do the following:

$ mysql -u root -p
mysql> create database wordpress;
mysql> create user wordpress@localhost identified by '<secure password>';
mysql> grant all privileges on wordpress.* to wordpress@localhost;
mysql> flush privileges;
mysql> exit

Now that MySQL is installed, you can install WordPress:

$ sudo apt-get install wordpress

Once this has completed, the final step is to configure Apache.

First, open the file "/etc/apache2/sites-enabled/000-default.conf" with an editor such as "vi" or "nano". Replace the contents of this file with the following:

<VirtualHost *:80>
       ServerAdmin webmaster@localhost
       ServerName <your-domain-name>
       ServerName localhost
       DocumentRoot /usr/share/wordpress

       <Directory /usr/share/wordpress>
           Options FollowSymLinks
           AllowOverride Limit Options FileInfo
           DirectoryIndex index.php
           Order allow,deny
           Allow from all
       </Directory>
       <Directory /usr/share/wordpress/wp-content>
           Options FollowSymLinks
           Order allow,deny
           Allow from all
       </Directory>

       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Second, create a file called "/etc/wordpress/config-<your-domain.name>.php" and add the following contents to it:

<?php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', '<secure-password>');
define('DB_HOST', 'localhost');
define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content');
?>

Third, restart Apache:

$ sudo service apache2 restart

Finally, open a web browser and go to your domain. You will be presented with a WordPress setup wizard. Once you've filled in the required information, you can begin using WordPress!

Backups

This document has shown you how to use the Rapid Access Cloud to deploy a website, but it has not covered all aspects of website administration, such as making off-site backups of your site. Procedures like this are outside the scope of this document, but we highly recommend getting this set up straight away.