- 下载jupyter。在服务器上下载并安装anaconda(anaconda自带jupyter)。
- 执行命令
upyter notebook --generate-config
,会在/home/zhangxuchang/.jupyter
文件夹下生成配置文件jupyter_notebook_config.py
。 - 执行命令
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout notebook_cert.key -out notebook_cert.pem
,会生成签名证书、notebook_cert.key 以及notebook_cert.pem(应该是在当前目录下,如果找不到你find一下)。 - 执行命令
python -c "import IPython;print(IPython.lib.passwd())"
生成一个sha1码。 - 在jupyter_notebook_config.py最后面追加以下内容:
c = get_config() c.NotebookApp.certfile = u'/root/.jupyter/notebook_cert.pem' # 步骤3生成的notebook_cert.pem文件 c.NotebookApp.keyfile = u'/root/.jupyter/notebook_cert.key' # 步骤3生成的notebook_cert.key文件 c.NotebookApp.password = u'sha1:e4c7da7f727d:3e891cc7b0126f30c1677b9d2d4ea7d42a1e7342' # 步骤4生成的sha1码 c.NotebookApp.ip = 'x.x.x.x' # 你自己服务器的ip c.NotebookApp.port = 8888 c.NotebookApp.open_browser = False
- 执行命令
jupyter notebook
。 - 在浏览器输入https://x.x.x.x:8889访问即可。注意,必须是https开头。
参考:http://baijiahao.baidu.com/s?id=1596866816908926760&wfr=spider&for=pc