Contents

How to Install Writefreely on Ubuntu 22.04

Installing writefreely is pretty much the same as installing wordpress, it’s quite easy and straightforward.

Install nginx & mysql-server

1
apt install nginx && mysql-server -y

Secure mysql & create the database

Secure mysql

After the insallation is completed, we need to run the following command to secure mysql:

1
mysql #log in to mysql

Replace my-secure-password with your own super strong password.

1
2
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'my-secret-password';
exit

Secure mysql:

1
mysql_secure_installation

/how-to-install-writefreely-on-ubuntu-22.04/images/mysql-installation-writefreely.png

Create the database

Log in to mysql

1
sudo mysql -u root -p

Create the database and the user

1
2
3
4
5
CREATE USER 'writefreely'@'localhost' IDENTIFIED BY 'another-super-secret-passward';
CREATE DATABASE writefreely CHARACTER SET latin1 COLLATE latin1_swedish_ci;
GRANT ALL PRIVILEGES ON writefreely . * TO 'writefreely'@'localhost';
FLUSH PRIVILEGES;
exit

Install writefreely

Find the latest version over https://github.com/writefreely/writefreely/releases

Download

1
2
3
4
5
cd /tmp
wget https://github.com/writefreely/writefreely/releases/download/v0.13.1/writefreely_0.13.1_linux_amd64.tar.gz
tar zxvf writefreely_0.13.1_linux_amd64.tar.gz
mkdir /var/www/writefreely
cp -a /tmp/writefreely/. /var/www/writefreely/

Configure writefreely

1
2
cd /var/www/writefreely
./writefreely config start

Fill in the configuration info

/how-to-install-writefreely-on-ubuntu-22.04/images/writefreely-config.jpg

The configuration file config.ini will be generated in the /var/www/writefreely folder.

Writefreely as a service

In order to set up Writefreely as a Systemd service, we need to do the following steps:

Create a file:

1
nano /etc/systemd/system/writefreely.service

Place the following content into the file, remember to change the dictionary name, in my case, it’s /var/www/writefreely

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
[Unit]
Description=Write Freely Instance
After=syslog.target network.target

[Service]
Type=simple
StandardOutput=syslog
StandardError=syslog
WorkingDirectory=/var/www/writefreely 
ExecStart=/var/www/writefreely/writefreely
Restart=always

[Install]
WantedBy=multi-user.target

Start the service

1
2
3
systemctl daemon-reload
sudo systemctl start writefreely
sudo systemctl enable writefreely

Configure Nginx

Create a new nginx config file

1
sudo nano /etc/nginx/sites-available/writefreely
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    gzip on;
    gzip_types
      application/javascript
      application/x-javascript
      application/json
      application/rss+xml
      application/xml
      image/svg+xml
      image/x-icon
      application/vnd.ms-fontobject
      application/font-sfnt
      text/css
      text/plain;
    gzip_min_length 256;
    gzip_comp_level 5;
    gzip_http_version 1.1;
    gzip_vary on;

    location ~ ^/.well-known/(webfinger|nodeinfo|host-meta) {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect off;
    }

    location ~ ^/(css|img|js|fonts)/ {
        root **/var/www/example.com**/static;
        # Optionally cache these files in the browser:
        # expires 12M;
    }

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect off;
    }
}

Create the admin user

1
./writefreely --create-admin username:password

Get the SSL

Install certbot on ubuntu 22.04

1
2
3
4
sudo snap install core; sudo snap refresh core
sudo apt remove certbot #remove the older version of certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot 

Obtaining an SSL Certificate

1
sudo certbot --nginx -d example.com -d www.example.com

All done! Visit official website https://writefreely.org/docs/v0.13.1 to get started.