今天在实验室的服务器主机上面搭建了jupyter notebook服务器,记录一下搭建步骤,方便以后查看。
服务器端操作
生成Jupyter Notebook配置文件
1
| $ jupyter notebook --generate-config
|
设置登录密码
1 2 3 4 5 6 7
| from notebook.auth import passwd passwd() Enter password: Verify password: Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
|
将生成的代码添加到配置文件中
1
| c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
|
修改配置文件
1
| $ vim ~/.jupyter/jupyter_notebook_config.py
|
在配置文件中添加如下内容
1 2 3 4 5 6 7 8 9
| c.NotebookApp.allow_origin = '*' c.NotebookApp.ip = '0.0.0.0' c.NotebookApp.port = 2021 c.NotebookApp.open_browser = False c.NotebookApp.notebook_dir = '/home/jupyter_projects' c.NotebookApp.allow_root = True c.NotebookApp.allow_remote_access = True c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
|
启动jupyter notebook
在终端输入如下命令启动jupyter notebook:
客服端电脑操作
1 2
| ssh username@ipaddress -L 2021:127.0.0.1:2021
|
最后在本地浏览器输入地址:127.0.0.1:2021 访问