Writefreely Tutorial . . .

. . . That Works

Two installations and both worked great. Problems you may have are not due to this tutorial.

I suggest using simple, a short alpha-numeric password for your installation and then changing it immediately upon going to admin, once installed, to an alpha-numeric-symbols password. This will make installation that much easier and avoid server glitches.

Installation is as root (sudo su – command) Ready? Let's Begin!

The first item is to create a user for the software: “writefreely” and sudo said user: “writefreely”.

For this we use the following commands


useradd -r -m -d /srv/writefreely -s /bin/bash writefreely

usermod -a -G www-data writefreely

su - writefreely


We then proceed to download the image of Writefreely from Github and unzip it and moving it into your “ domain.com” –> (mv is Linux for “move”)


wget https://github.com/writefreely/writefreely/releases/download/v0.15.0/writefreely_0.15.0_linux_amd64.tar.gz

tar xvzf writefreely_0.15.0_linux_amd64.tar.gz

mv writefreely domain.com

exit

chown writefreely:www-data -R /srv/writefreely/


We install maridb and create the database:


apt install mariadb-server

mysql -u root -p 

CREATE DATABASE writefreely;

GRANT ALL PRIVILEGES ON writefreely.* TO 'your_user'@'localhost' IDENTIFIED BY 'pass123';

exit

(We Suggest keeping password (above) alpha-numeric)


Now we generate the configuration of writefreely. Remember that you must change domain.com by your domain:



su - writefreely

cd yourdomain.com

./writefreely --config


In the generated file, we will modify the following data: username = user password = alpha-numeric database = writefreely sitename = Name, not URL (this can differ from URL) sitedescription = Descripción del blog host = https://domain.com default_visibility = public


Once the file is modified we save it (control + X, and we give it to itself). Then we type the following codes to generate the encryption key and the administrator user.


./writefreely db init

./writefreely keys generate

./writefreely --create-admin youadmin:simple pass

We will create the service in Systemd and add its content from the root user (you have to exit the writefreely user, if you don't know it's just writing exit):


Exit

nano /etc/systemd/system/writefreely.service


Copy/Paste to terminal (Change multi-user.target to single-user.target if you did not choose multi-user in config)


[Unit]
Description=WriteFreely Instance
After=syslog.target network.target mysql.service

[Service]
Type=simple 
StandardOutput=syslog 
StandardError=syslog 

User=writefreely
Group=www-data

WorkingDirectory=/srv/writefreely/domain.com

ExecStart=/srv/writefreely/domain.com/writefreely

Restart=always  

[Install] 
WantedBy=multi-user.target

Once Done we save the file (control + X, Y, and ENTER to save) then continue:


systemctl daemon-reload 

systemctl start writefreely 

systemctl enable writefreely


Now we will start a very important part, to configure Nginx:


apt install nginx certbot python3-certbot-nginx


Then, edit by Copy/Paste the below paragraphs remembering to change domain.com to your domain


nano /etc/nginx/sites-available/writefreely.conf


With the last code we have created a file where we will write the following, remembering to change domain.com for your domain:


Copy/Paste to terminal


	server {
        listen 80;
        listen [::]:80;

          server_name domain.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 /srv/writefreely/domain.com/static;
    }

    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;
       }
    }

We save the file and enable it: Control X, Y, Enter


cd /etc/nginx/sites-enabled/ 

ln -s ../sites-available/writefreely.conf 

nginx -t 

systemctl reload nginx


And to finish, we install certbot:


apt install -y certbot python3-certbot-nginx

certbot


When initializing certbot it will ask a series of questions that you must answer. The answers, in order are: Yes (Y), No (N), (1) – (no parentheses). enter your email address for the admin (you?) and if you accept the Terms of Service from Certbot (Y). The certificate will be generated. After generation, if you've done it correctly enter https://YOURDOMAIN.NAME in your browser and you are ready.

The login is done with the username and password that you named in previous steps. (See note below.)

(When installing use a simple, short password at first.) This can easily be changed in Admin. Pay attention and you will soon be gazing at a website just like this.