|
|
|
## Installation von »Jupyter Notebook«
|
|
|
|
|
|
|
|
»Jupyter Notebook« ist eine web-basierte interaktive Umgebung zur Erzeugung von
|
|
|
|
Jupyter-Notebook-Dokumenten (oft Python-Programme mit zugehöriger
|
|
|
|
Dokumentation).
|
|
|
|
|
|
|
|
Nachfolgend werden Hinweise zur Installation unter openSUSE 15.1 gegeben. Sie
|
|
|
|
gelten sinngemäß auch für andere systemd-basierte Linux-Distributionen.
|
|
|
|
|
|
|
|
### Installation der nötigen Pakete
|
|
|
|
```
|
|
|
|
zypper in --recommends apache2 python3-jupyter_ipython
|
|
|
|
```
|
|
|
|
|
|
|
|
### Apache-Konfiguration eines virtuellen Hosts für »Jupyter Notebook« (Port 82)
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cat <<EOF > /etc/apache2/vhosts.d/notebook.conf
|
|
|
|
Listen 82
|
|
|
|
|
|
|
|
<VirtualHost *:82>
|
|
|
|
ProxyPass / http://127.0.0.1:8888/
|
|
|
|
ProxyPassReverse / http://127.0.0.1:8888/
|
|
|
|
# spoof headers to make notepad accept the request as coming from the same origin
|
|
|
|
Header set Origin "http://127.0.0.1:8888/"
|
|
|
|
RequestHeader set Origin "http://127.0.0.1:8888/"
|
|
|
|
LogLevel debug
|
|
|
|
<Location /api/kernels/>
|
|
|
|
ProxyPass ws://127.0.0.1:8888/api/kernels/
|
|
|
|
ProxyPassReverse ws://127.0.0.1:8888/api/kernels/
|
|
|
|
</Location>
|
|
|
|
<Location /ipython/terminals/websocket/>
|
|
|
|
ProxyPass ws://127.0.0.1:8888/ipython/terminals/websocket/
|
|
|
|
ProxyPassReverse ws://127.0.0.1:8888/ipython/terminals/websocket/
|
|
|
|
</Location>
|
|
|
|
</VirtualHost>
|
|
|
|
|
|
|
|
EOF
|
|
|
|
```
|
|
|
|
|
|
|
|
### Systemd-Service-Datei zum Starten oder Stoppen des Servers
|
|
|
|
|
|
|
|
```
|
|
|
|
cat <<EOF > /usr/lib/systemd/system/ipython-notebook.service
|
|
|
|
# README:
|
|
|
|
# Copy this file to /usr/lib/systemd/system/
|
|
|
|
# sudo systemctl daemon-reload
|
|
|
|
# systemctl enable ipython-notebook
|
|
|
|
# systemctl start ipython-notebook
|
|
|
|
# The WorkingDirectory and ipython-dir must exist
|
|
|
|
# If you don't want anything fancy, go to http://127.0.0.1:8888 to see your notebook
|
|
|
|
# wheneber you want it
|
|
|
|
|
|
|
|
[Unit]
|
|
|
|
Description=IPython notebook
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=simple
|
|
|
|
PIDFile=/var/run/ipython-notebook.pid
|
|
|
|
ExecStart=/usr/bin/jupyter notebook --notebook-dir=/home/ipynb/notebooks --no-browser --profile=nbserver --NotebookApp.allow_origin="http://127.0.0.1:82"
|
|
|
|
User=ipynb
|
|
|
|
Group=ipynb
|
|
|
|
WorkingDirectory=/home/ipynb/notebooks
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
|
|
|
EOF
|
|
|
|
```
|
|
|
|
|
|
|
|
### Konfiguration
|
|
|
|
|
|
|
|
Das Folgende ist unter dem root-Account bzw. mit root-Rechten auszuführen:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
a2enmod proxy
|
|
|
|
a2enmod proxy_html
|
|
|
|
a2enmod proxy_http
|
|
|
|
a2enmod headers
|
|
|
|
a2enmod proxy_wstunnel
|
|
|
|
|
|
|
|
useradd --create-home --system --user-group ipynb
|
|
|
|
mkdir /home/ipynb/notebooks
|
|
|
|
chown -R ipynb.ipynb /home/ipynb
|
|
|
|
```
|
|
|
|
|
|
|
|
Das Folgende ist unter dem Account des Nutzers `ipynb` auszuführen:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
su - ipynb
|
|
|
|
|
|
|
|
ipython profile create nbserver
|
|
|
|
|
|
|
|
# Setzen des Passworts
|
|
|
|
|
|
|
|
python3
|
|
|
|
Python 3.5.2 (default, Sep 14 2016, 11:28:32)
|
|
|
|
[GCC 6.2.1 20160901 (Red Hat 6.2.1-1)] on linux
|
|
|
|
Type "help", "copyright", "credits" or "license" for more information.
|
|
|
|
>>> from notebook.auth import passwd
|
|
|
|
>>> passwd() # below I enter "password123"
|
|
|
|
Enter password:
|
|
|
|
Verify password:
|
|
|
|
'sha1:????????????:??????'
|
|
|
|
```
|
|
|
|
|
|
|
|
In `/home/ipynb/.jupyter/jupyter_notebook_config.py` eintragen (unbedingt unter
|
|
|
|
ipynb-Account!):
|
|
|
|
```
|
|
|
|
c.NotebookApp.password = 'sha1:????????????:??????'
|
|
|
|
```
|
|
|
|
|
|
|
|
Das Folgende ist unter dem root-Account bzw. mit root-Rechten auszuführen:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
systemctl enable apache2.service
|
|
|
|
systemctl start apache2.service
|
|
|
|
systemctl enable ipython-notebook.service
|
|
|
|
systemctl start ipython-notebook.service
|
|
|
|
```
|
|
|
|
|
|
|
|
### Zugriff
|
|
|
|
|
|
|
|
Der Serverzugriff entsprechend der hier gezeigten Installation erfolgt über
|
|
|
|
`http://HOSTNAME:82/`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|