You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jupyterpi/html/INSTALLATION_NOTES.md

134 lines
3.0 KiB
Markdown

---
title: Installation notes
---
## Tinc
Installed tinc following pzwiki guide!
## NGINX config
sudo apt install nginx
Added user directories to nginx setup
```
# enable home directories ... eg ~USER/ => /home/USER/public_html/index.html
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
index index.html index.htm;
autoindex on;
}
```
Made the /var/www/html folder belong to group users
sudo chgrp users /var/www/html
sudo chmod -R 2775 /var/www/html
NB: The 2 turns on the setGID bit meaning:
> newly created subfiles inherit the same group as the directory, and newly created subdirectories inherit the set GID bit of the parent directory.
### Reverse proxies for jupyter
```
location /lab/mmurtaugh/ {
proxy_pass http://localhost:9050/;
include /etc/nginx/includes/lab.conf;
}
```
And made a file for common settings (nb: replace sandbot with correct path):
sudo nano /etc/nginx/includes/lab.conf
```
rewrite /(.*) /sandbot/$1 break;
error_page 502 /lab/502.html;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
```
## Jupyter config
First installed pip3 & updated it...
sudo apt install python3-pip
sudo pip3 install --upgrade pip
Then used pip3 to install jupyterlab...
sudo pip3 install jupyterlab
Following [this guide](http://sonny-qa.github.io/2017/11/16/jupyter-notebook-ec2-reverse-proxy/), configured my local jupyter to use port 9050, and setup config
To [set the password](http://ipython.org/ipython-doc/stable/notebook/public_server.html):
python3
from IPython.lib import passwd
passwd()
Copied by "password hash"
jupyter notebook --generate-config
nano ~/.jupyter/jupyter_notebook_config.py
```
c.NotebookApp.base_url = '/sandbot/lab/mmurtaugh/'
c.NotebookApp.port = 9050
c.NotebookApp.trust_xheaders = True
c.NotebookApp.port_retries = 50
c.NotebookApp.password = 'sha1:PASSWORD_HASH_FROM_ABOVE'
c.NotebookApp.allow_remote_access = True
```
Followed [this tutorial](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-jupyterlab-environment-on-ubuntu-18-04#step-6-%E2%80%94-setting-up-a-systemd-service) on creating a systemd service. Used my username (and group).
sudo nano /etc/systemd/system/jupyterlab@.service
```
[Unit]
Description=Jupyter Lab Server (%i)
After=nginx.service
[Service]
User=%i
Group=%i
Type=simple
WorkingDirectory=/home/%i/
ExecStart=/usr/local/bin/jupyter-lab --config=/home/%i/.jupyter/jupyter_notebook_config.py
StandardOutput=null
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
```
Then you can
sudo systemctl enable jupyterlab@mmurtaugh
or
sudo systemctl start jupyterlab@mmurtaugh
and
sudo systemctl status jupyterlab@mmurtaugh