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