Simple install How To

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.

2 Likes

Thanks for taking the time to write this, @lhl! This will be a huge help for others.

Just to mention: there were a few bugs around user creation when using SQLite, which will be fixed in v0.7 (coming out later today), so that should work for people soon. Otherwise, do you have the last log message before everything seems to stop during the config / setup process? That might be a different bug we need to fix.

No worries. It’s not great, just a simple step by step in my user case.

I don’t have a copy of the log. the

./writefreely --config

does its thing and leaves the terminal cursor hanging. It’s done it on each and every occasion as I’ve gone through the process. I simply Ctrl+C out.

Other than leaving you in mid-air doesn’t seems to have any other impact that I can tell.

Ah, I see. Could you try it again whenever you have a chance, and let me know what the last message is where it hangs?

You said you used Digital Ocean, any other hosting providers that can be suitable for this purpose? I am also not great at understanding how this stuff works but sometimes, the plans of Digital Ocean are a little to much when converted to Indian rupees. Please let me know, if you have any more suitable alternatives.

I don’t use Digital Ocean - just their online Guides, which I have found useful. Other providers I know are Linode, Vultr - who I have used in the past, and Amazon Web Services (AWS) who I use currently. AWS has a Free Tier for the first 12 months on some of its services. Works out at only a few USD per month.

Will do.

AWS EC2 Instance. Clean install with Ubuntu 18.04 LTS.
Clean install of Nginx

sudo apt update

sudo apt upgrade

Writefreely uploaded via FileZilla.

Here is a copy and paste of the terminal:

./writefreely --config
No config.ini configuration yet. Creating new.

✍ Write Freely Configuration ✍

This quick configuration process will generate the application's config
file, config.ini.

It validates your input along the way, so you can be sure any future
errors aren't caused by a bad configuration. If you'd rather configure your
server manually, instead run: writefreely --create-config and edit that
file.

Server setup 
Production, behind reverse proxy
Local port: 8080

Database setup 
SQLite
Filename: writefreely.db

App setup 
Single user blog
Admin username: *******
Admin password: *******
Blog name: test
Public URL: http://*************
Enabled
Private
Private
2019/01/08 10:39:23 Connecting to sqlite3 database...
2019/01/08 10:39:23 Creating user *******...

Following command shows nothing related to WriteFreely:

tail -f /var/log/syslog

If you can suggest other avenues, I’m happy to leave this server set as is and test further.

A post was split to a new topic: Moving from WordPress

Thanks, that helps. So it does look like that was the issue we recently fixed – you shouldn’t see it anymore in v0.7.

I just tried again with v0.7 and all is good except:

ERROR: 2019/01/08 18:55:27 log.go:26: Rolling back users INSERT: no such table: users
ERROR: 2019/01/08 18:55:27 log.go:26: Unable to create user: no such table: users

Solved by running:

./writefreely --init-db

before

./writefreely --config

So you might want to make that adjustment in the Getting Started info… :slight_smile:

1 Like

Yes, I too got the same error and fixed it in the exact same manner, even in my localhost.

Actually, having tried again. You cannot run

init-db

before

config

I tried that route just now. So had to run config then init-db and then run config a second time…

1 Like

Yes. Correct. Forgot to mention that.

Yep, will fix this issue as well in the next release.

2 Likes

By the way, this is fixed in v0.7.1, which was just released.

2 Likes

I just added a bug for the --init-db --config issue, but now I see it is a known issue and addressed in 0.7.1. I’ll remove my Githib bug.

1 Like

@lhl hey this guide you gave is really helpful. I plan to start on Scaleway but have you tried with the secure option yet? Do you know how to do it? I know one thing that we have to use 443 but apart from that what all procedures from Let’s Encrypt? Details please if you have done it.

Cheers, am just a bloke on the street with no documented experience, just personal trial and error…

I have a https version of my blog now. I used the following to set up:

CertBot

It’s part of Let’s Encrypt - really easy to follow, you’ll need to be able to SSH to your server.

1 Like

@lhl BTW, I heard that the free tier on Amazon EC2 runs out quickly. How many months have you been running your blog? If you are paying already then what is the cost. I need to be sure before I jump anywhere.