WriteFreely - VPS with Nginx and mysql.
Disclaimer: Getting WriteFreely up and running on a VPS for the person on the street - in other words ‘for the layperson’. I am very far away from being a developer type. I can put a basic website together and upload it to a server; cope with very, very simple problem solving in code etc; that’s about it. So this guide is pretty simple from these perspectives.
External links to Digital Ocean are guides that I found easy to follow, there is a lot of other info and resources out there… I have no affiliation to DO.
Set up your server at the VPS of your choice. I am using an AWS EC2 instance running Ubuntu 18.04 LTS.
Using terminal (I’m running Antegros Linux), but should be similar in other environments…
Update, Upgrade, Secure this as per your requirements.
Install Nginx.
A basic explanation of how to go about this here: Digital Ocean Guide
sudo apt install nginx
Install mysql-server.
I tried to get up and running with SQlite, but had no luck - probably something to do with permissions, but I could not get the WriteFreely config to write to the database.
sudo apt install mysql-server
sudo mysql_secure_installation
Follow the basic instructions here Digital Ocean Guide
Logout of mysql.
mysql> exit
Check it is running.
sudo systemctl status mysql.service
Ctrl+C to return to prompt.
Login to mysql.
sudo mysql -u $USER -p
mysql> CREATE DATABASE writefreely;
mysql> FLUSH PRIVILEGES;
mysql> exit
If you haven’t already, download WriteFreely and extract. I do this locally on my drive, then upload to the server using FileZilla.
I upload into a dedicated directory under the HOME dir not to /var/www/html.
Once this has finished, run:
./writefreely --config
Follow the Installer/Setup Q’s.
Use Ctrl+C to get back to the prompt when all seems to stop…
Run:
./writefreely --init-db
This will write the database tables into the database you created earlier.
Run:
./writefreely --gen-keys
Create a Admin User.
./writefreely --create-admin $USER:$PASSWORD
Refer to the documentation here Getting Started if needed.
I’m running the app in a Reverse Proxy. So:
sudo nano /etc/nginx/conf.d/writefreely.conf
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; } }
Copy and paste the above, ensuring you change bold values to your requirements.
Ctrl+X, Y, ENTER to save and return to the prompt.
Note
I’ve not done so yet, but at this point you might want to add a 443 server block to the above file with your requirements from a Let’s Encrypt certificate and keys.
Next, to start the app when you boot and to keep it live:
sudo nano /etc/systemd/system/writefreely.service
[Unit] Description=Write Freely Instance After=syslog.target network.target [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
Again, change bold values to suit.
Reload Nginx
sudo nginx -s reload
Start WriteFreely.
sudo systemctl start writefreely
verify:
sudo journalctl -f -u writefreely
There should be no errors showing in the read-out… if there is, the best place to start for answers would be the forum Discuss write.as: writefreely.
Head over to your IP address and you will see your app up and running.
Login using the details you entered at ./writefreely --create-admin $USER:$PASSWORD
Once you are logged in Explore. Most settings can be found under the Customize menu option.
Write your first post…
Best of luck. M.