Warning
This article is old, and some of the information may be outdated or no longer valid today.
If you have any questions or need to confirm any details, we recommend contacting our support team for up-to-date information and personalized assistance.
The Project Jupyter is a nonprofit organization created to "develop open-source software, open standards, and services for interactive computing across dozens of programming languages" (created from IPython by Fernando Pérez). Jupyter supports runtime environments in several dozen programming languages. The Jupyter project name refers to the three main programming languages supported by Jupyter, which are Julia, Python and R, and is also a tribute to Galileo's notebooks recording the discovery of Jupiter's satellites. The Jupyter project has developed and supported the interactive computing products Jupyter Notebook, JupyterHub, and JupyterLab, the next-generation version of Jupyter Notebook.
Preliminary steps and Jupyter installation
First, update the repositories and packages:
# apt update && apt upgradeOnce updated, you will need to install the required packages:
# apt install nginx python3-certbot-nginx python3-pip python3-dev python3-virtualenvNext, delete and/or create a file for the NGINX site:
# rm /etc/nginx/sites-enabled/default && vi /etc/nginx/sites-enabled/defaultThis file must contain the following configuration (remember to change the example domain):
##
# top-level http configuration for websocket headers
# If Upgrade is defined, Connection = upgrade
# If Upgrade is empty, Connection = close
# Please see https://jupyterhub.readthedocs.io/en/stable/reference/config-proxy.html for more details.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name ejemplo.com;
location / {
proxy_pass https://127.0.0.1:8888;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# websocket headers
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Scheme $scheme;
proxy_buffering off;
}
}
Once you have saved the changes, you can obtain the certificate with Certbot:
# certbot --nginx --redirect -d ejemplo.comNext, for security reasons, it is recommended not to use the root user. Therefore, create a user for the project:
# useradd clouding && usermod -aG sudo cloudingAdditionally, create a directory for the environment and change its ownership:
# mkdir /home/clouding && chown clouding:clouding /home/cloudingAnd open a session as the user:
# su cloudingThen go to the directory you created:
# cd /home/clouding/To create the virtual environment for Jupyter:
# virtualenv jupyter created virtual environment CPython3.8.10.final.0-64 in 206ms
creator CPython3Posix(dest=/home/clouding/jupyter, clear=False, global=False)
seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/clouding/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
Once created, you will need to enter the environment directory:
# cd jupyter/And activate it:
# source bin/activateNow, inside the environment, you can install Jupyter:
(jupyter) # pip install jupyterOnce installation is complete, create the configuration file:
(jupyter) # jupyter notebook --generate-configBy default, Jupyter is accessed using tokens, but you can use a password:
(jupyter) # jupyter notebook passwordNext, edit the configuration file:
# vi /home/clouding/.jupyter/jupyter_notebook_config.pyTo uncomment and modify the following lines:
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.certfile = u'/etc/letsencrypt/live/ejemplo.com/fullchain.pem'
c.NotebookApp.keyfile = u'/etc/letsencrypt/live/ejemplo.com/privkey.pem'
Once configured, you can run Jupyter:
(jupyter) # jupyter notebook [I 17:00:41.941 NotebookApp] Writing notebook server cookie secret to /home/clouding/.local/share/jupyter/runtime/notebook_cookie_secret
[I 17:00:42.230 NotebookApp] Serving notebooks from local directory: /home/clouding/jupyter
[I 17:00:42.230 NotebookApp] Jupyter Notebook 6.4.10 is running at:
[I 17:00:42.230 NotebookApp] ejemplo.com:8888/
[I 17:00:42.230 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Alternatively, if you want it to start automatically, you can create a service with systemd. To do this, create a file for the service:
# vi /etc/systemd/system/jupyter.serviceWith the following contents:
[Unit]
Description=jupyter daemon
After=network.target
[Service]
User=clouding
Group=clouding
WorkingDirectory=/home/clouding/jupyter
ExecStart=/bin/bash -c 'source /home/clouding/jupyter/bin/activate; jupyter notebook'
[Install]
WantedBy=multi-user.target
Finally, enable and start the service you created:
# systemctl enable jupyter.service && systemctl start jupyter.service && systemctl status jupyter.serviceWe hope this article has helped you🙂. Remember, if you have questions about this or any other issue related to your servers at Clouding, feel free to write to soporte@clouding.io We're here for whatever you need!