搭建服务器端jupyter notebook环境并通过外网访问

搭建服务器端jupyter notebook环境并通过外网访问

  • 一、安装Jupyter
  • 二、生成 notebook 配置文件
  • 三、Jupyter密码配置
  • 四、修改Jupyter配置文件
  • 五、 启动jupyter notebook
  • 六、远程访问 Notebook

一、安装Jupyter

若已经安装了Anaconda,就无需再安装jupyter,若无,则输入

pip install jupyter

二、生成 notebook 配置文件

使用下列命令生成配置文件:

 jupyter notebook --generate-config

三、Jupyter密码配置

复制生成的密钥

ipython
In [1]: from notebook.auth import passwd
In [2]: passwd()

搭建服务器端jupyter notebook环境并通过外网访问_第1张图片

四、修改Jupyter配置文件

使用vim打开配置文件

$ vim ~/.jupyter/jupyter_notebook_config.py

打开 jupyter_notebook_config.py 配置文件,修改下面几处:

c.NotebookApp.ip = '*' 或者‘0.0.0.0’ 所有绑定服务器的IP都能访问,若想只在特定ip访问,输入ip地址即可
c.NotebookApp.password = u'sha:ce...刚才复制的那个密码'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888    #随便指定一个端口,但是要记住
c.NotebookApp.allow_remote_access = True
c.NotebookApp.notebook_dir = u'目录'  #这个是根目录,不想配置就不配置,默认是用户家目录

搭建服务器端jupyter notebook环境并通过外网访问_第2张图片

五、 启动jupyter notebook

服务器端启动:

jupyter notebook

服务器让jupyter后台运行的方法:

nohup jupyter notebook --allow-root  >> logs.out 2>&1 &

六、远程访问 Notebook

打开浏览器,输入http://公网ip地址:8888
搭建服务器端jupyter notebook环境并通过外网访问_第3张图片

你可能感兴趣的:(深度学习,深度学习,linux,python)