From 2d36537e73f0aaa40d9ef0dac2ff1d74e20cd653 Mon Sep 17 00:00:00 2001 From: Rui Carmo Date: Sun, 17 Jun 2018 12:26:19 +0100 Subject: [PATCH] Add Ubuntu 18.04 docs --- .python-version | 1 + docs/SCRIPTS.md | 2 +- docs/ubuntu-18.04-bionic.md | 92 +++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .python-version create mode 100644 docs/ubuntu-18.04-bionic.md diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..019c7c9 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +anaconda3-4.3.1 diff --git a/docs/SCRIPTS.md b/docs/SCRIPTS.md index 16d4abd..8ad0975 100644 --- a/docs/SCRIPTS.md +++ b/docs/SCRIPTS.md @@ -1,6 +1,6 @@ # Ubuntu 16.04 -Full installation sequence on a blank machine: +Full installation sequence on a blank Ubuntu 16.04 machine: ```bash sudo apt-get update diff --git a/docs/ubuntu-18.04-bionic.md b/docs/ubuntu-18.04-bionic.md new file mode 100644 index 0000000..d37c5c5 --- /dev/null +++ b/docs/ubuntu-18.04-bionic.md @@ -0,0 +1,92 @@ +# Installation on Ubuntu 18.04 LTS (Bionic) + +> This is a standalone, distribution-specific version of `INSTALL.md`. You do not need to read or follow the original file, but can refer to it for generic steps like setting up SSH keys (which are assumed to be common knowledge here) + +`piku` setup is simplified in Bionic, since it can take advantage of some packaging improvements in [uWSGI][uwsgi] and does not require a custom `systemd` service. Since Bionic also ships with Python 3.6, this is an ideal environment for new deployments on both Intel and ARM devices. + +## Dependencies + +Before installing `piku`, you need to install the following packages: + +```bash +# this also installs python3-click as a dependency +sudo apt-get install -y build-essential certbot git incron \ + libjpeg-dev libxml2-dev libxslt1-dev zlib1g-dev nginx \ + python-certbot-nginx python-dev python-pip \ + python-virtualenv python3-dev python3-pip python3-virtualenv \ + uwsgi uwsgi-plugin-asyncio-python3 uwsgi-plugin-gevent-python \ + uwsgi-plugin-python uwsgi-plugin-python3 uwsgi-plugin-tornado-python +``` +## Setting up the `piku` user + +`piku` requires a separate user account to run. To create a new user with the right group membership (we're using the built-in `www-data` group because it's generally thought of as a less-privileged group), enter the following commands: + +```bash +# pick a username +export PAAS_USERNAME=piku +# create it +sudo adduser --disabled-password --gecos 'PaaS access' --ingroup www-data $PAAS_USERNAME +``` + +This user _is not supposed to login to your system_. Instead, you'll interact with `piku` via SSH, and set things up by using `su`: + +```bash +# copy your public key to /tmp (I'm assuming it's the first entry in authorized_keys) +head -1 ~/.ssh/authorized_keys > /tmp/pubkey +# install piku and have it set up SSH keys and default files +sudo su - $PAAS_USERNAME -c "wget https://raw.githubusercontent.com/rcarmo/piku/master/piku.py && python3 ~/piku.py setup && python3 ~/piku.py setup:ssh /tmp/pubkey" +rm /tmp/pubkey +``` + +The `setup` output should be something like this: + +``` +Creating '/home/piku/.piku/apps'. +Creating '/home/piku/.piku/repos'. +Creating '/home/piku/.piku/envs'. +Creating '/home/piku/.piku/uwsgi'. +Creating '/home/piku/.piku/uwsgi-available'. +Creating '/home/piku/.piku/uwsgi-enabled'. +Creating '/home/piku/.piku/logs'. +Setting '/home/piku/piku.py' as executable. +``` + +## uWSGI Configuration + +[uWSGI][uwsgi] in Bionic requires very little configuration, since it is already properly packaged. All you need to do is place a link to the `piku` configuration file in `/etc/uwsgi/apps-enabled`: + +```bash +sudo ln /home/$PAAS_USERNAME/.piku/uwsgi/uwsgi.ini /etc/uwsgi/apps-enabled/piku.ini +sudo systemctl restart uwsgi +``` + +## `nginx` Configuration + +`piku` requires you to edit `/etc/nginx/sites-available/default` to the following, so it can inject new site configurations into `nginx`: + +``` +server { + listen 80 default_server; + listen [::]:80 default_server; + root /var/www/html; + index index.html index.htm; + server_name _; + location / { + try_files $uri $uri/ =404; + } +} +# replace `PAAS_USERNAME` with the username you created. +include /home/PAAS_USERNAME/.piku/nginx/*.conf; +``` + +## `incron` Configuration + +To detect configuration changes and tell `nginx` to activate new `piku` sites, we use `incron`. Create `/etc/incron.d/paas` with the following contents: + +```bash +# replace `PAAS_USERNAME` with the username you created. +/home/PAAS_USERNAME/.piku/nginx IN_MODIFY,IN_NO_LOOP /bin/systemctl reload nginx +``` +> This file was last updated on June 2018 + +[uwsgi]: https://github.com/unbit/uwsgi