# 'Slightly' Less simple install How To

**URL:** <https://discuss.write.as/t/slightly-less-simple-install-how-to/303>\
**Category:** Installation\
**Tags:** writefreely\
**Created:** [January 21, 2019, 4:06pm UTC](https://discuss.write.as/t/slightly-less-simple-install-how-to/303 "2019-01-21T16:06:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lhl](https://discuss.write.as/user_avatar/discuss.write.as/lhl/32/103_2.png) [@lhl](https://discuss.write.as/u/lhl)\
**Post date:** [January 21, 2019, 4:06pm UTC](https://discuss.write.as/t/slightly-less-simple-install-how-to/303/1 "2019-01-21T16:06:34Z")

</div>

# Install **WriteFreely v.0.7.1** - Ubuntu 18.04, Nginx, SQLite - based on an AWS EC2 instance.

**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.

You’ll need to be comfortable with the Terminal/Command Line, as you are probably setting **WriteFreely** up to self-host then I expect this is the case.

Whilst this works for me, a more experienced Developer/Programmer etc will have differing perspectives and solutions. Also your user case might not exactly match my own.

**SSH to your server**

As the logged in $USER

Update, Upgrade and Secure your server to your requirements

`sudo apt update`

`sudo apt upgrade -y`

**Install Nginx**

`sudo apt install nginx`

Set up UFW - Uncomplicated Firewall

`sudo ufw allow 'Nginx HTTP'`

`sudo ufw allow 'OpenSSH'`

`sudo nginx enable`

`sudo ufw status`

Check status of Nginx

`systemctl status nginx`

Output:

```auto
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-04-20 16:08:19 UTC; 3 days ago
     Docs: man:nginx(8)
 Main PID: 2369 (nginx)
    Tasks: 2 (limit: 1153)
   CGroup: /system.slice/nginx.service
           ├─2369 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           └─2380 nginx: worker process

```

Go to:

`http://your_server_ip`

Confirm that the server is running. You should see the Nginx landing page.

If not already download **WriteFreely** to your local machine.

[WriteFreely](https://github.com/writeas/writefreely/releases/tag/v0.7.1)

Unzip to a local folder.

**Back in Terminal/Command Line.**

Ensure you are in the HOME folder. Usually called something like `/home/$USER`

create a new folder `sudo mkdir -p /home/$USER/writefreely/`

Assign ownership of the directory

`sudo chown -R $USER:$USER /home/$USER/writefreely/`

The permissions of your web roots should be correct if you haven’t modified your umask value, but you can make sure by typing:

`sudo chmod -R 755 /home/$USER/writefreely`

Make a new server block at /etc/nginx/sites-available/example.com:

`sudo nano /etc/nginx/sites-available/writefreely`

Paste in, ensure to change **bold** values to your needs:

```
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 **/home/$USER/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;
    }
}
```

Save and close the file when you are finished.

Enable the file by creating a link from it to the sites-enabled directory:

`sudo ln -s /etc/nginx/sites-available/writefreely /etc/nginx/sites-enabled/`

To avoid a possible hash bucket memory problem that can arise from adding additional server names, it is necessary to adjust a single value in the /etc/nginx/nginx.conf file. Open the file:

`sudo nano /etc/nginx/nginx.conf`

Find the server\_names\_hash\_bucket\_size directive and remove the # symbol to uncomment the line:  
/etc/nginx/nginx.conf

```
http {
    ...
    server_names_hash_bucket_size 64;
    ...
}
```

Test for syntax errors:

`sudo nginx -t`

Restart Nginx to enable your changes:

`sudo systemctl restart nginx`

Using your favourite FTP program upload the **WriteFreely** files to the `/home/$USER/writefreely` directory.

Once done:

`cd writefreely`

`./writefreely --config`  
Follow the prompts.

`./writefreely --init-db`

`./writefreely --gen-keys`

`./writefreely --create-admin username:password`

Set **WriteFreely** up as a service.

`sudo nano etc/systemd/system/writefreely.service`

Paste:

```auto
[Unit]
Description=Write Freely Instance
After=syslog.target network.target

[Service]
Type=simple
StandardOutput=syslog
StandardError=syslog
WorkingDirectory=/home/$USER/writefreely
ExecStart=/home/$USER/writefreely/writefreely
Restart=always

[Install]
WantedBy=multi-user.target

```

Restart Nginx:

`sudo systemctl restart nginx`

Start the service:

`sudo systemctl start writefreely`

Visit your ip:

`http://your_server_ip`

If you have a registered domain you can now set up **Let’s Encrypt** via the **Certbot** plugin.

Visit `https://certbot.eff.org/` . Select Nginx and Ubuntu 18.04LTS

`sudo apt-get update`

`sudo apt-get install software-properties-common`

`sudo add-apt-repository universe`

`sudo add-apt-repository ppa:certbot/certbot`

`sudo apt-get update`

`sudo apt-get install python-certbot-nginx`

Run to let CertBot automatically set up:

`sudo certbot --nginx`

---

<div class="post-metadata">

**Author:** ![matt](https://discuss.write.as/user_avatar/discuss.write.as/matt/32/2760_2.png) [@matt](https://discuss.write.as/u/matt)\
**Post date:** [January 21, 2019, 8:20pm UTC](https://discuss.write.as/t/slightly-less-simple-install-how-to/303/2 "2019-01-21T20:20:01Z")

</div>

Thanks for writing this up! Just a small improvement I’d make for getting WriteFreely onto your server – instead of downloading and FTPing everything, you can run this on your server:

```bash
# TODO: Set this to the exact version number you want
export WFVER=0.7.1

# Download the archive
wget https://github.com/writeas/writefreely/releases/download/v$WFVER/writefreely_${WFVER}_linux_amd64.tar.gz

# Unzip it to your installation directory (~/writefreely in this case)
mkdir -p /home/$USER/writefreely
tar -C /home/$USER/writefreely -xzf writefreely_${WFVER}_linux_amd64.tar.gz

```

---

<div class="post-metadata">

**Author:** ![lhl](https://discuss.write.as/user_avatar/discuss.write.as/lhl/32/103_2.png) [@lhl](https://discuss.write.as/u/lhl)\
**Post date:** [January 21, 2019, 8:23pm UTC](https://discuss.write.as/t/slightly-less-simple-install-how-to/303/3 "2019-01-21T20:23:26Z")

</div>

Thanks for adding this.

I’d looked for a way to skip the FTP route, but it wasn’t obvious to me 🙂

---

<div class="post-metadata">

**Author:** ![staticpixel](https://discuss.write.as/user_avatar/discuss.write.as/staticpixel/32/97_2.png) [@staticpixel](https://discuss.write.as/u/staticpixel)\
**Post date:** [January 24, 2019, 6:18am UTC](https://discuss.write.as/t/slightly-less-simple-install-how-to/303/4 "2019-01-24T06:18:27Z")

</div>

> [@lhl](#):
>
> `sudo ufw status`
> 
> Check status of Nginx

You forgot to add a statement here. By default the status of Nginx shows inactive. You have to write  
`sudo ufw enable`  
for it to be active.

---

<div class="post-metadata">

**Author:** ![staticpixel](https://discuss.write.as/user_avatar/discuss.write.as/staticpixel/32/97_2.png) [@staticpixel](https://discuss.write.as/u/staticpixel)\
**Post date:** [January 24, 2019, 7:24am UTC](https://discuss.write.as/t/slightly-less-simple-install-how-to/303/5 "2019-01-24T07:24:59Z")

</div>

> [@lhl](#):
>
> `systemctl status nginx`
> 
> Output:
> 
> ```auto
> ● nginx.service - A high performance web server and a reverse proxy server
> Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
> Active: active (running) since Fri 2018-04-20 16:08:19 UTC; 3 days ago
> Docs: man:nginx(8)
> Main PID: 2369 (nginx)
> Tasks: 2 (limit: 1153)
> CGroup: /system.slice/nginx.service
> ├─2369 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
> └─2380 nginx: worker process
> 
> ```

At this point I ran into the following Nginx PID error.

 ![image](https://discuss.write.as/uploads/default/original/1X/9c4a998bf61c271202e163727d0f608eaa3e864b.png)

And I found a solution to that error [here](https://www.cloudinsidr.com/content/heres-fix-nginx-error-failed-read-pid-file-linux/) but I was unable to solve it. It shows no errors now but going to the public IP address doesn’t display anything at all.

---

<div class="post-metadata">

**Author:** ![staticpixel](https://discuss.write.as/user_avatar/discuss.write.as/staticpixel/32/97_2.png) [@staticpixel](https://discuss.write.as/u/staticpixel)\
**Post date:** [January 26, 2019, 6:06pm UTC](https://discuss.write.as/t/slightly-less-simple-install-how-to/303/6 "2019-01-26T18:06:28Z")

</div>

@matt Is there any issue or particular problem that I might run into if I use **Standalone Server** instead of **Reverse Proxy**? Please let me know.

---

<div class="post-metadata">

**Author:** ![colin-axner](https://discuss.write.as/user_avatar/discuss.write.as/colin-axner/32/919_2.png) [@colin-axner](https://discuss.write.as/u/colin-axner)\
**Post date:** [September 11, 2020, 1:52pm UTC](https://discuss.write.as/t/slightly-less-simple-install-how-to/303/7 "2020-09-11T13:52:33Z")

</div>

I just set up an instance and this helped a lot (along with the install on the write freely site).

One issue that I ran into unmentioned here is this:

`sudo ufw allow 'Nginx HTTPS'`

I believe should be ran if you use certbot? At least that fixed a connection issue for me

---

<div class="post-metadata">

**Author:** ![SamBamThankYouMan](https://discuss.write.as/letter_avatar_proxy/v4/letter/s/5f8ce5/32.png) [@SamBamThankYouMan](https://discuss.write.as/u/SamBamThankYouMan)\
**Post date:** [October 10, 2020, 7:01pm UTC](https://discuss.write.as/t/slightly-less-simple-install-how-to/303/8 "2020-10-10T19:01:14Z")

</div>

I followed these steps. The blog is up and running (thanks!!) but it’s not able to fetch `static` files. All of them are giving 403 errors. I’ve tried playing around with Nginx and permissions, to no avail. Do you have any ideas what the problem might be?

If this is helpful, I’m logging into the server as root, and Nginx is running as www-data.

---

<div class="post-metadata">

**Author:** ![omitsch](https://discuss.write.as/letter_avatar_proxy/v4/letter/o/ce7236/32.png) [@omitsch](https://discuss.write.as/u/omitsch)\
**Post date:** [April 10, 2023, 8:17pm UTC](https://discuss.write.as/t/slightly-less-simple-install-how-to/303/9 "2023-04-10T20:17:51Z")

</div>

Hey, i need some help to set up writefreely on an oracle ubuntu arm instance.

I already have one website running on my server but as soon as in add the **WF.conf** in **/etc/nginx/sites-available/** and link it to **/etc/nginx/sites-enabled/** i get an error while running “ **sudo nginx -t** ”.

I did edit **nginx.conf** as in the guide but my ubuntu instance tells me

```auto
nginx: [emerg] unknown "user" variable
nginx: configuration file /etc/nginx/nginx.conf test failed

```

What am i doing wrong? What could be the issue?

BTW: As server\_name I’m using an unique adress from DuckDns that uses the same IP as my first website, could this be the issue? I also didnt change the “proxy\_pass” ports that are bold in the WF.conf file, is this the issue? I dont really know what a proxy pass is. The user in nginx.conf is “www-data”.
