Please enable JavaScript to view the comments powered by Disqus.

My WriteFreely Setup

A derivation work of

Today, I had to migrate my blog from hosting it in AWS to DigitalOcean. Before I began hosting my blog, I already had a t2.micro EC2 instance running as part of my experimentation with Linux. I thought it was convenient to host my blog in that same server. Well, it was... until the bill came. Apparently, the instance is only free for the first 12 months. After that, AWS charges me for a whopping $18/mo. Freak. I decided to switch to DO to reduce the cost to $6/mo.

It took me a couple hours to re-setup everything. So, I'm writing this in case I ever need to do the same. Perhaps this would save me some time.

Warning: I have NOT tested everything below. I merely picked commands from my history and cross-reference them to the link I gave above

# Set up OS

# Set up WriteFreely
# Install nginx & certbot
$ sudo apt install -y nginx certbot python3-certbot-nginx

# Install mysql
$ wget
$ sudo dpkg -i mysql-apt-config*
$ sudo apt install mysql-community-server mysql-server

# Create a writefreely system user (good practice)
$ sudo useradd -r -m -d /srv/writefreely writefreely

# Install WriteFreely
$ cd /srv/writefreely
$ wget
$ sudo -u writefreely tar xfvz writefreely_0.13.1_linux_amd64.tar.gz
$ sudo -u writefreely mv writefreely

# Prepare DB
$ sudo mysql
mysql> CREATE DATABASE writefreely CHARACTER SET latin1 COLLATE latin1_swedish_ci;
mysql> CREATE USER 'writefreely'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON writefreely.* TO 'writefreely'@'localhost'; 

# Copy over config

# Copy over dump file
ubuntu@old-node~$ sudo mysqldump writefreely > dump.sql
ubuntu@old-node~$ scp dump.sql teddy@new-node
teddy@new-node~$ mysql -u writefreely -p writefreely < dump.sql

# Copy / create a WriteFreely service (same as theo andreo's)
$ systemctl daemon-reload 
$ systemctl enable --now writefreely.service
$ curl localhost:8080  # test

# Copy / create nginx config (same as theo andreo's)
# Replace ->
$ cd /etc/nginx/sites-enabled/
$ sudo  ln -s ../sites-available/
$ sudo nginx -t && sudo systemctl reload nginx

# Set up certbot
$ sudo certbot --nginx