diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..054628d --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,40 @@ +# Installing Treebird + +## Compiling + +You need the following libraries / packages: + +- libcurl + - Debian: `libcurl4-gnutls-dev` +- libcjson + - Debian: `libcjson-dev` + - Arch: `cjson` +- libpcre3 + - Debian: `libpcre3-dev` + +First, edit `config.h` to your instance's liking. + +`make` will clone the library, and compile both it and the project. + +`make update` should be run after updating, as it ensures both the library and the project are up to date. + +## Deploying + +After running `make`, Treebird's files will be in the `dist/` directory. _Copy_, ***DO NOT MOVE***, **everything but treebird.cgi** of this folder to your web server. Copy `treebird.cgi` to another directory of your choosing. + +- The example static files will be in `/var/www/treebird/`, with `treebird.cgi` in `/usr/local/bin/treebird.cgi`. + +### Using NGINX (and uWSGI) to serve Treebird +Treebird can be served over nginx by using a CGI server such as uwsgi. + +#### nginx +An example nginx configuration is available in [treebird.nginx.conf](./treebird.nginx.conf). +* Make sure to change `example.com` to your instance's domain. +* Make sure to change the `root` to wherever the static files are being stored + +#### uWSGI +uWSGI can be installed on debian with just `sudo apt isntall uwsgi`. + +An example configuration is available in [treebird.uwsgi.ini](./treebird.uwsgi.ini). This should be copied to `/etc/uwsgi/apps-enabled/treebird.ini` on debian (and potentially other) systems. + +##### Note: the uwsgi configuration file is currently very basic. \ No newline at end of file diff --git a/README.md b/README.md index 4a30ae7..c390fc5 100644 --- a/README.md +++ b/README.md @@ -14,5 +14,8 @@ No. ## Credits -Please view the `CREDITS` file. +Please view the [`CREDITS`](./CREDITS) file. +## Installing + +See [INSTALL.md](./INSTALL.md) diff --git a/treebird.nginx.conf b/treebird.nginx.conf new file mode 100644 index 0000000..bcf7b74 --- /dev/null +++ b/treebird.nginx.conf @@ -0,0 +1,38 @@ +server { + + root /var/www/treebird; + server_name treebird.example.com; + +location @treebird { + include uwsgi_params; + uwsgi_modifier1 9; + uwsgi_pass unix:///run/uwsgi/treebird.sock; + } + + location / { + root /var/www/treebird; + try_files $uri @treebird; + } + + listen [::]:443 ssl; # managed by Certbot + listen 443 ssl; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/treebird.example.com/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/treebird.example.com/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + +} +server { + if ($host = treebird.example.com) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + listen 80; + listen [::]:80; + + server_name treebird.example.com; + return 404; # managed by Certbot + + +} \ No newline at end of file diff --git a/treebird.uwsgi.ini b/treebird.uwsgi.ini new file mode 100644 index 0000000..5c47c69 --- /dev/null +++ b/treebird.uwsgi.ini @@ -0,0 +1,7 @@ +[uwsgi] +master = true +plugins = cgi +socket = /run/uwsgi/%n.sock +uid = www-data +gid = www-data +cgi = /usr/local/bin/treebird.cgi \ No newline at end of file