How To Install a Write Freely Blog

How to Install Write Freely Blog

Write Freely federated blogging software provides you with everything you would need to run a successful blog in the style of Medium or Substack, but it’s hosted on your own server, giving you more control and creative expression.

This article presumes that you are starting your Write Freely installation with either a brand new virtual private server (VPS), or a VPS that already has a website on it. Either way, you will be installing Write Freely as a “reverse proxy” with NGINX as opposed to a “standalone” server. This means if you want to have other websites installed alongside your Write Freely blog, you can simply add them to your NGINX configuration.

In order to complete this tutorial you will need to have root access and a running MySQL server installed.

Create a MySQL Database For Write Freely

In order to run a Write Freely blog you will need to make sure that you have a MySQL server running. Like most content management systems, Write Freely dynamically generates pages from content stored in the MySQL database. This article does not cover installation of MySQL. However, once you have installed MySQL, you can proceed with creating a database user and a database for the Write Freely installation.

Setting Up The MySQL Database User

If you already have a user with access to all databases, you can skip this step. But if not, go ahead and log into into MySQL:

mysql -u root -p

Provide your root password. Once logged in, create the user:

mysql> CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Now that you have created a user you can grant privileges. This command will grant the user privilege to all databases.

mysql> GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';

Flush privileges to reload:

mysql> FLUSH PRIVILEGES;

Create A Database For Write Freely

To create a database for your Write Freely installation, you will just need to log into MySQL as the root user and run this command:

CREATE DATABASE writefreely CHARACTER SET latin1 COLLATE latin1_swedish_ci;

Install the Write Freely Core Files

Now that you have a database installed, you are ready to install Write Freely and start blogging.

Get a Fresh Copy of Write Freely

It’s time to log into your server and proceed to the directory from which you would like to server your Write Freely installation. In most Debian-based systems the /var/www/html directory is already set up to host your static files. In this article, you will use that directory, but feel free to swap it out with any directory you want to use.

Access the latest release of Write Freely from their GitHub account. You can easily use wget to download the source tarball.

First, change into your web root directory:

cd /var/www/html

Then download the files:

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

Open the archived file with tar:

tar -xf writefreely_0.13.1_linux_amd64.tar.gz 

You will now have a writefreely directory in your web root. Change into that directory:

cd writefreely

You are now ready to configure your installation.

Update NGINX Configuration

Before your website goes live, you need to add it to your NGINX configuration. Be sure to check out our full guide on how to edit your NGINX configuration file if you are unfamiliar with that process.

The Write Freely documentation helpfully provides an example NGIX reverse proxy configuration:

The values set in bold face can be customized for your installation. Most importantly, of course, change example.com to the domain from which you want to serve your Write Freely blog.

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/html/writefreely/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;
    }
}

Configure Your Write Freely Installation

You are now ready to configure the Write Freely installation itself. Write Freely provides a walk-through setup wizard that lets you configure the base settings. To get there, navigate to the working directory (in our case, /var/www/html/writefreely) and run this command:

./writefreely config start

Next, generate keys for the project:

./writefreely keys generate

Finally, when you run the program, you will see your website go live:

./writefreely

However, once you stop the program, the website will go down. You need to set up Write Freely as a service that will run in the background of your server. Follow the final steps below to complete the installation.

Set Up Writefreely As a Service

We are going to set up Write Freely as a service in Systemd, following along with the Write Freely recommended settings in the documentation.

Create a file:

/etc/systemd/system/writefreely.service

And place this content into the file:

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

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

[Install]
WantedBy=multi-user.target

Of course, be sure to update these lines with the appropriate file paths. For our example, they would look like this:

WorkingDirectory=/var/www/html/writefreely
ExecStart=/var/www/html/writefreely/writefreely

Now, start the service, and you’re good to go:

sudo systemctl start writefreely

Your Write Freely blog is live, and it will stay live. You can check that the service is running with the following command:

sudo journalctl -f -u writefreely

Well done! You now know how to set up a Write Freely blog.

With our Cloud VPS plans, you can deploy a lightning-fast, reliable cloud platform with built-in redundancy – ensuring the availability of your environment!
CM
Christopher Maiorana Content Writer II

Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.

More Articles by Christopher

Was this article helpful? Let us know!