Cryogen

Static sites generated with Clojure

Virtual Private Servers (VPS), such as those provided by DigitalOcean, are an excellent way to host a site with static content for around $5 per month. Here's a quick rundown on how to serve your content with Nginx on VPS running Ubuntu.

Setting up Nginx

The first thing you'll need to do is install Nginx if you don't already have it on your server.

$ sudo apt-get install nginx

Next, you'll want to create a directory for your site's content and make it public. For the purposes of this guide, let's suppose we're on a user called deploy with sudo permissions.

$ mkdir ~/site
$ chmod 755 ~/site

Next, you'll want to make a backup of the default configuration in /etc/nginx/sites-available/default and replace it with one of the following:

Configuration for sites with no blog-prefix

server {
 listen 80;

 root            /home/deploy/site;
 index           index.html index.htm;

 server_name     YOURDOMAIN.COM www.YOURDOMAIN.COM;

 access_log      /var/log/nginx/access.log;
 error_log       /var/log/nginx/error.log;

 location / {
   default_type  "text/html";
   alias         /home/deploy/site/;
   try_files     $uri.html $uri $uri/ =404;
   error_page    404 = /404.html;
 }
}

Simply set YOURDOMAIN.COM to the domain of your site in the configuration and ensure the static content is available at /home/deploy/site/. Finally, place your custom error page in the /home/deploy/site/404.html file.

Configuration for sites with a blog-prefix

If you've provided a blog-prefix in your Cryogen configuration you will have to reflect that in your nginx configuration file.

server{
 listen 80;

 root            /home/deploy/site;
 index           index.html index.htm;
 error_page      404 = /404.html;

 server_name  YOURDOMAIN.COM www.YOURDOMAIN.COM;

 access_log      /var/log/nginx/access.log;
 error_log       /var/log/nginx/error.log;

 location / {
   default_type  "text/html";
   try_files     $uri.html $uri $uri/ =404;
 }

 location /BLOG-PREFIX/ {
   alias         /home/deploy/site/BLOG-PREFIX/;
 }
}

Simply set YOURDOMAIN.COM to the domain of your site in the configuration and ensure the static content is available at /home/deploy/site/BLOG-PREFIX/. Finally, place your custom error page in the /home/deploy/site/404.html file.

Once you've changed your nginx configuration file, restart nginx.

$ sudo service nginx restart

Deploying Your Site

When your server is ready to serve your site, you'll need to upload your site to your server to start serving your content. You can do this with a FTP client such as FileZilla or with the scp command from the terminal.

If you'd like to change or add more content to your site after you get it up and running, simply transfer the content generated by Cryogen once again.