Skip to content

Instantly share code, notes, and snippets.

@anton-petrov
Last active February 28, 2022 09:18
Show Gist options
  • Save anton-petrov/f31ac8b8504ab9ed99c4e152ffec11be to your computer and use it in GitHub Desktop.
Save anton-petrov/f31ac8b8504ab9ed99c4e152ffec11be to your computer and use it in GitHub Desktop.
Installing JupyterHub on Linux Ubuntu (Debian)
[Unit]
Description=JupyterHub
[Service]
Type=simple
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/anaconda3/bin"
ExecStart=/usr/bin/env jupyterhub --port=10001
User=root
Group=root
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
@anton-petrov
Copy link
Author

First install Anaconda3, then NodeJS, Jupyter Hub, configurable-http-proxy.

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh -O ~/anaconda3.sh
sudo bash ~/anaconda3.sh -b -p /opt/anaconda3
sudo apt-get install -y nodejs
sudo npm i -g configurable-http-proxy

Change permissions:
'ds' means Data Science.

 groupadd ds
 chgrp -R ds /opt/anaconda3/
 chmod 770 -R /opt/anaconda3/
 adduser ${USER} ds

Activate conda:

eval "$(/opt/anaconda3/bin/conda shell.bash hook)"
conda init

Install JupyterHub:
sudo python3 -m pip install jupyterlab notebook jupyterhub

Test your installation. If installed, these commands should return the packages’ help contents:

jupyterhub -h
configurable-http-proxy -h

Start the Hub server

To start the Hub server, run the command:
jupyterhub

Visit http://localhost:8000 in your browser, and sign in with your unix credentials.

To allow multiple users to sign in to the Hub server, you must start jupyterhub as a privileged user, such as root:

sudo jupyterhub

Create JupyterHub.service file and copy paste content to it from this gist:

sudo nano /etc/systemd/system/JupyterHub.service

Start a systemd service named JupyterHub and autostart it on boot. It is running on port 10001.

sudo systemctl start JupyterHub.service
sudo systemctl status JupyterHub.service

If the config file needs to be edited, run sudo systemctl daemon-reload after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment