1. 生成jupyter notebook的配置文件,命令:
jupyter notebook --generate-config
会生成文件~~./jupyter/jupyter_notebook_config.py
2. 生成sha1码,需要在python环境中生成。相关命令:
>>> from notebook.auth import passwd
>>> passwd()
Enter password:
Verify password:
'sha1:c0633cb7e6e8:477687eb5050086aa7adc6bfbad4b26179c77'
3. 编辑vim ~./jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha1:ce...刚才生成的sha1码'
c.NotebookApp.allow_remote_access = True #允许远程访问
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888
c.NotebookApp.notebook_dir = 'dir' # 设置的目录
4. 防火墙打开端口配置的8888,需要在root用户下执行
firewall-cmd --zone=public --add-port=8888/tcp --permanent # 打开端口
firewall-cmd --reload # 重新加载生效
firewall-cmd --zone=public --list-ports # 查看打开端口
5. 后台一直运行jupyter notebook供远程访问,命令
nohup jupyter notebook &