pip3 install jupyter notebook
- 生成配置
jupyter notebook --generate-config
- 配置一般在
~/.jupyter/jupyter_notebook_config.py
中
- 设置密码及设置工作目录
## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = '/root/jupyter_notebooks'
## Whether to open in a browser after starting. The specific browser used is
...
# To generate, type in a python/IPython shell:
#
# from notebook.auth import passwd; passwd()
#
# The string should be of the form type:salt:hashed-password.
c.NotebookApp.password = 'sha1:ff737af759e0:5fdc6a7df25b9af4912204ced9ca309336defe8f'
- 修改密码,使用python生成密码的密钥
from notebook.auth import passwd; print(passwd("123456"))
- 生成密码后,替换掉那一串字符
- 启动服务
# 正常启动(前台运行)
$ jupyte-notebook --config ~/.jupyter/jupyter_notebook_config.py
# 后台运行
$ mkdir jupyter_notebooks
$ nohup jupyter-notebook --config .jupyter/jupyter_notebook_config.py 1>jupyter_notebooks/jupyter.log 2>&1 &
- 测试是否成功
$wget 127.0.0.1:8888
--2020-01-11 10:49:58-- http://127.0.0.1:8888/
Connecting to 127.0.0.1:8888... connected.
HTTP request sent, awaiting response... 302 Found
Location: /tree? [following]
--2020-01-11 10:49:58-- http://127.0.0.1:8888/tree?
Reusing existing connection to 127.0.0.1:8888.
HTTP request sent, awaiting response... 302 Found
Location: /login?next=%2Ftree%3F [following]
--2020-01-11 10:49:58-- http://127.0.0.1:8888/login?next=%2Ftree%3F
Reusing existing connection to 127.0.0.1:8888.
HTTP request sent, awaiting response... 200 OK
Length: 9113 (8.9K) [text/html]
Saving to: ‘index.html’
100%[===================================================================>] 9,113 --.-K/s in 0s
2020-01-11 10:49:58 (208 MB/s) - ‘index.html’ saved [9113/9113]
- 设置防火墙通过8888端口
iptables -A INPUT -p tcp -m tcp --dport 8080 -j accept
or
firewall-cmd --permanent --add-port=8888/tcp
firewall-cmd --reload
- 打开浏览器,访问
http://ip:8888