DigitalOcean PerlVerse
Choosing your droplet size
There will be some resource intensive Perl setup work involved out of the gate, but then after that verse + nginx will require very few resources to run.As such, to get started I recommend spinning up the smallest droplet. Currently, that's the $5/mo. tier with 512 GB RAM and 20 GB SSD. Once the droplet has started, you can go into the console, shut down the droplet, resize the CPU and Memory only, and power the droplet back on. DigitalOcean has how to do this documented here. Personally, I upped this droplet to the $40/mo. tier during setup, which lasted less than an hour. After setup was complete, I downgraded back to the $5/mo tier.
Just as a final reminder, even though DigitalOcean covers this on their instructions as well: if you change the disk capacity as well as CPU and memory, you cannot downgrade back. You can only downgrade if you've upgraded CPU and memory only.
Initial Setup
Ubuntu
- Spin up an Ubuntu droplet
- Run:
sudo apt-get update && sudo apt-get upgrade -y
- Create a user account, replacing
$USER
with your desired username:
sudo adduser $USER && sudo usermod -aG sudo $USER
- Setup the user with a password using
sudo passwd $USER
and/or give your user passwordless sudo. sudo su - $USER
- Install some useful software:
sudo apt-get install nginx git htop tmux vim tree ack-grep perl-doc build-essential -y
- Get the best collection of rc files this side of the Mississippi:
cd ~ && git clone https://github.com/jhunt/env && cd env && ./install && source ~/.bashrc
- Make sure you can ssh as your new user:
mkdir ~/.ssh && chmod 700 ~/.ssh && vim ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys
- Clone verse:
cd /your/desired/directroy && git clone https://github.com/jhunt/verse && cd verse
Perl Dependencies
Ubuntu does have a Perl installation by default, you just need to update it and install the packages. First thing is to update cpan
. You can update cpan
by simply entering that very commad at the prompt. When it starts the initial setup you will be asked if you want it to autoconfigure - select 'yes'. Once it's complete run the following in CPAN:
install Bundle::CPAN
This will take a while to complete. At some points there will be some user input for a test to pass before continuing, so maybe get a snack but stay nearby. nce complete, run:
reload cpan
Once that's complete, use exit
to exit. Now we're going to install the motherload in tandem:
cpan install Module::Build && cpan install Hash::Merge && cpan install Template && cpan install Time::ParseDate && cpan install Test::Exception && cpan install Test::Output && cpan install File::Slurp && cpan install YAML:Old
Once that's all complete, from in the verse directory, run:
perl Build.PL
This makes a binary named Build
. You'll see a warning about a missing manifest, so next we'll create the manifest, test, and install (if the test passes):
./Build manifest
./Build test
./Build install
I highly recommend not skipping the ./Build test
step - this will let you know if anything is missing before attempting to install and there may have been changes since this post was written.
Using your Verse
You'll want to create a www diretory for your blog, something like:
sudo mkdir /var/www/myblogname
Then go into the blog directory and build your new verse blog:
cd /var/www/myblogname
verse new
Nginx
This is useful when editing posts to see how they render before rebuilding verse. To run verse long term, you'll need to set up nginx. Here's a sample nginx config to help you get started. Note the FIXME
sections that you'll most likely need to adjust to your blog configuration.
events {
worker_connections 768;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server {
listen 80;
listen [::]:80;
server_name myblogname.com; #FIXME: your blog's address, can use IP if you haven't set up a domain name
default_type text/html;
location / {
root /var/www/myblogname/htdocs; #FIXME: change to your blog name
index index.html index.htm;
access_log /var/log/nginx/myblogname.access.log main; #FIXME: change to your blog name
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
}
DigitalOcean has an excellent write up to help you get started with nginx.
Writing posts
You create posts using YAML files in /var/www/myblogname/data/blog
. A sample blog post, named first.yml
, shows the structure of the YAML post file. The entry itself is after the header information and respects Markdown syntax so **bold** is bold, etc. To view you posts in dev mode prior to publishing them, run verse run
. This runs an instance of verse
on port 4000
, e.g. if the IP of your droplet is 10.10.10.10
you can view your blog in a broswer at 10.10.10.10:4000
. To publish your posts, use verse build
.