Skip to content
SaeHie Park edited this page Aug 16, 2020 · 39 revisions

Settings

Run Jupyter-notebook as a Service at http://localhost:3010/

Apache2 will proxy http://localhost:3010/ to http://domain.com/jupyter/

prerequisite

sudo apt-get update

sudo apt-get install python-is-python3
# or use update-alternatives command

sudo apt-get install build-essential libssl-dev libffi-dev
sudo apt-get install python3-pip python3-dev
sudo apt-get install ipython3

python -m pip install --upgrade pip
python -m pip install --upgrade numpy
python -m pip install --upgrade jupyter
python -m pip install --upgrade ipykernel
python -m ipykernel install --user --name [virtualEnv] --display-name "[displayKenrelName]"

Look inside and edit ~/.local/share/jupyter/kernels/

python3 -m ipykernel install --user --name=[venv_name]

replace venv_name with your virtual env name

create config file

jupyter notebook --generate-config

will create

/home/pi/.jupyter/jupyter_notebook_config.py

create password

$ python
Python 2.7.9 (default, Sep 17 2016, 20:26:04)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from notebook.auth import passwd; passwd()
Enter password:
Verify password:
'sha1:whatever-the-result'

set config

c.NotebookApp.base_url = '/jupyter/'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:whatever-the-result'
c.NotebookApp.port = 3010

to run without apache proxy

c.NotebookApp.ip = '192.168.1.100'

set apache2 proxy to foward to internet

enable proxy

sudo a2enmod proxy
sudo a2enmod proxy_http

in mods-enabled/proxy.conf file

        ProxyPass /jupyter http://127.0.0.1:3010/jupyter
        ProxyPassReverse /jupyter http://127.0.0.1:3010/jupyter

restart apache2

service

Create a file

/etc/systemd/system/jupyter.service
[Unit]
Description=Jupyter-Notebook

[Service]
Type=simple
PIDFile=/run/jupyter-notebook.pid
ExecStart=/usr/local/bin/jupyter-notebook --config=/home/pi/.jupyter/jupyter_notebook_config.py
User=pi
Group=pi
WorkingDirectory=/var/jupyter
Restart=always
RestartSec=30

[Install]
WantedBy=multi-user.target

Add www-data user to ubuntu group in /etc/group file

register and restart

sudo systemctl restart apache2
sudo systemctl reenable jupyter.service
sudo systemctl restart jupyter.service
Clone this wiki locally