Install WriteFreely with Apache and MySQL

Hi all,

After stumbling across WriteFreely quite recently, I was eager to give it a go. I spun up a VM and went about installing it, using Apache as the web server (I’m more familiar with this than Nginx) and MySQL as the db backend (was looking to integrate WF into an existing web server with MySQL already in use). Here’s my guide on getting it setup, along with obtaining an SSL certificate via Let’s Encrypt. I used Ubuntu Server 18.04 as my OS. This guide is for a fresh install, so adapt it if you already have a server. I use ‘’ as a placeholder for your own URL. So long as you’re DNS records are updated, you can use a subdomain such as ‘’.

Update & upgrade system
sudo apt update && sudo apt dist-upgrade

Install Apache
sudo apt install apache2

Start Apache
sudo systemctl start apache2

Install MySQL
sudo apt install mysql-server

Configure MySQL
Decide yourself on the how you want it setup
sudo mysql_secure_installation

Enable Apache modules
These modules allow us to use Apache as a reverse proxy
sudo a2enmod proxy
sudo a2enmod proxy_http

Restart Apache
sudo systemctl restart apache2

Create MySQL Database
Can leave password blank when prompted
sudo mysql -u root -p

When at the mysql> prompt:
CREATE USER 'writefreely'@'localhost' IDENTIFIED BY 'YouPasswordHere';
CREATE DATABASE IF NOT EXISTS writefreely CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES on writefreely.* to 'writefreely'@'localhost';

Create and change to directories
sudo mkdir /var/www/
sudo mkdir /var/www/
cd /var/www/

Download WriteFreely
Get the link for the latest Linux version from HERE. If you’re using SSH from a device you have internet access to, an easy way to do this is to right-click the link for the Linux version, which is writefreely_0.9.1_linux_amd64.tar.gz at time of typing, and select Copy Link Location (or your web browser equivalent). Then, simply paste the link into the command below.
sudo wget LINK

Uncompress downloaded file
Adapt for version you downloaded
sudo tar -xvzf writefreely_0.9.1_linux_amd64.tar.gz

Remove file
No need for it after we have uncompressed it
sudo rm writefreely_0.9.1_linux_amd64.tar.gz

Configure WriteFreely

  • Choose Production, behind reverse proxy
  • Keep local port as 8080
  • Choose MySQL enter the details for the MySQL database (as per my example, writefreely as both username and database name, then the password you chose)
  • Choose if you want a Single user blog or Multi-user instance (doesn’t matter either way)
  • Enter admin details (if Single user blog was chosen above)
  • Use the URL you want to use for WriteFreely as the Public URL
  • Make whichever choice you want for Federation, Federation usage stats and Instance metadata privacy

sudo ./writefreely --config

Import schema for multi-user setup and create admin user - only if you chose Multi user instance above
sudo ./writefreely --init-db
sudo ./writefreely --create-admin [username]:[password]

Generate data encryption keys
sudo ./writefreely --gen-keys

Create Virtual Host for Apache
sudo nano /etc/apache2/sites-available/writefreely.conf

<VirtualHost *:80>

    ProxyPreserveHost On

    ProxyPass /
    ProxyPassReverse /

Enable Virtual Host
sudo a2ensite writefreely.conf

Disable existing default Virtual Host
sudo a2dissite 000-default.conf

Reload Apache
sudo systemctl reload apache2

Create systemd service
sudo nano /etc/systemd/system/writefreely.service

Description=Write Freely Instance



Enable service
This will then start the service every time the system boots
sudo systemctl enable writefreely.service

Start service
sudo systemctl start writefreely.service

Install certbot - for Let’s Encrypt SSL certificate
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot
sudo apt-get install certbot python-certbot-apache

Run certbot
Select the URL you want to add the SSL certificate for, then choose whichever options after.
sudo certbot --apache

That should be you. Please let me know if I’ve made any mistakes, or if there are easier ways to do what I’ve done. I can’t say I’m an expert with Linux, so would greatly appreciate feedback.


This is awesome. Thanks for writing it up and sharing, @kingprawn22!

1 Like