Linux 安装 Jupyter notebook

Posted by Sunday on 2019-07-01

官方文档

安装启动

1
2
3
yum install -y python-devel
pip install --upgrade pip
pip install jupyter

启动

1
jupyter notebook --ip 0.0.0.0 --allow-root

访问

1
http://ip:8888

设置密码

1
2
jupyter notebook --generate-config
jupyter notebook password

禁止启动浏览器

1
2
vim /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.open_browser = False

supervisor守护

1
2
3
4
5
6
7
8
9
[program:jupyter]
command=/usr/bin/jupyter notebook --ip 0.0.0.0 --allow-root
directory=/home/sunday/jupyter
user=root
autostart=true
autostart=true
autorestart=true
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log

代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
server {
listen 80;
server_name jupyter.sundayle.com;
charset utf-8;
location ~* /(api/kernels/[^/]+/(channels|iopub|shell|stdin)|terminals/websocket)/? {
proxy_pass http://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 support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

}
}

https://www.voidking.com/dev-centos-jupyter/