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.
- Create a MySQL Database For Write Freely
- Install the Write Freely Core Files
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:
Then download the files:
Open the archived file with
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:
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.
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:
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:
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:
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.