Ubuntu 16.04远程配置Jupyter Notebook
安装和配置Jupyter Notebook
安装jupyter notebook
conda
conda install -c conda-forge notebook
pip
pip install notebook
安装好之后,运行:
jupyter notebook
看是否能成功运行
配置Jupyter notebook
- 首先生成配置文件:
sudo jupyter notebook --generate-config - 然后修改位于
~/.jupyter/jupyter_notebook_config.py处的配置文件:- notebook文件根目录:
## The directory to use for notebooks and kernels.
# Default: ''
c.NotebookApp.notebook_dir = '<PATH_TO_DIR>'
- notebook文件根目录:
## The port the notebook server will listen on (env: JUPYTER_PORT).
# Default: 8888
c.NotebookApp.port = 51234
- notebook文件根目录:
- 运行命令:
jupyter notebook --no-browser --config=<ABSPATH_TO_CONFIG>/.jupyter/jupyter_notebook_config.py
把jupyter notebook的启动合成到一个命令
为启动notebook的命令设置别名:
alias jlremote='jupyter notebook --no-browser --config=<ABSPATH_TO_CONFIG>/.jupyter/jupyter_notebook_config.py'
然后将这句命令添加到~/.bashrc和~/.bash_profile,如果是Mac OS则添加到~/.zshrc
之后运行:
jlremote
即可。为了使notebook能在后台运行,可以用screen命令为其单开一个screen运行。
把jupyter notebook作为linux service运行
sudo vim /etc/systemd/system/jupyter.service
在这个文件里填入
[Unit]
Description=Jupyter Notebook
[Service]
WorkingDirectory=<PATH_TO_DIR>
ExecStart=<ABSPATH_TO_CMD>/jupyter notebook --no-browser --config=<ABSPATH_TO_CONFIG>/.jupyter/jupyter_notebook_config.py
Restart=always
RestartSec=10
SyslogIdentifier=jupyter-notebook
User=<USER NAME>
[Install]
WantedBy=multi-user.target
然后安装并运行该服务:
sudo systemctl enable jupyter.service
sudo systemctl start jupyter.service
sudo systemctl status jupyter.service
远程连接jupyter
使用SSH隧道
在~/.bashrc和~/.bash_profile,如果是Mac OS则在~/.zshrc添加:
function jllocal {
port=YOUR PORT
remote_username=USERNAME
remote_hostname=HOSTNAME
url="http://localhost:$port"
echo "Opening $url"
open "$url"
cmd="ssh -CNL localhost:"$port":localhost:"$port" $remote_username@$remote_hostname"
echo "Running '$cmd'"
eval "$cmd"
}
在本地机里直接运行jllocal即可。
使用nginx反向代理
首先直接安装nginx:
sudo apt install nginx
我们需要把本地访问URL<YOUR DOMAIN NAME/IP>:<YOUR PORT>/jupyter时重定向到远程服务器访问localhost:<YOUR_PORT>/jupyter。
配置文件在:/etc/nginx里,可以在conf.d文件夹下新建jupyter.conf,写入配置:
upstream notebook {
server localhost:<YOUR PORT>;
}
server{
listen 80;
server_name <YOUR DOMAIN NAME/IP>;
location /jupyter {
proxy_pass http://notebook;
proxy_set_header Host $host;
}
location ~ /jupyter/api/kernels/ {
proxy_pass http://notebook;
proxy_set_header Host $host;
# websocket support
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
location ~ /jupyter/terminals/ {
proxy_pass http://notebook;
proxy_set_header Host $host;
# websocket support
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
}
然后也需要修改jupyter的配置~/.jupyter/jupyter_notebook_config.py:
# Local IP addresses (such as 127.0.0.1 and ::1) are allowed as local, along
# with hostnames configured in local_hostnames.
# Default: False
c.NotebookApp.allow_remote_access = True
## DEPRECATED use base_url
# Default: '/'
c.NotebookApp.base_project_url = '/jupyter/'
修改完配置之后重启两个服务:
sudo systemctl restart jupyter.service
sudo systemctl restart nginx.service
然后可以在本地浏览器里输入<YOUR DOMAIN NAME/IP>:<YOUR PORT>/jupyter访问notebook server,第一次可能需要登录token。
如果把jupyter放到服务里运行的话,token可以从以下log里找到:
sudo systemctl status jupyter.service
Ubuntu 16.04远程配置Jupyter Notebook的更多相关文章
- Ubuntu 16.04 LTS 配置 Jupyter notebook 为服务器
原材料: Ubuntu 16.04 LTS 64bit 已经配置好 IPython 和 Jupyter (安装步骤可以参照:http://www.cnblogs.com/McKean/p/619497 ...
- [eShopOnContainers 学习系列] - 03 - 在远程 Ubuntu 16.04 上配置开发环境
直接把 md 粘出来了,博客园的富文本编辑器换成 markdown,没啥效果呀 ,先凑合吧.实在不行换地方 # 在远程 Ubuntu 16.04 上配置开发环境 ## 零.因 为什么要用这么麻烦的 ...
- Ubuntu 16.04修改配置静态IP和DNS
Ubuntu 16.04修改配置静态IP和DNS 1.修改interfaces 文件 sudo gedit /etc/network/interfaces 2.添加 例如: auto enp0s25 ...
- Ubuntu 16.04 Bridge配置
Ubuntu 16.04 Bridge配置 一.安装网桥拓展包 bridge-utils root@ubuntu:~# apt-get install bridge-utils 二.创建网桥设备 // ...
- 【转】Ubuntu 16.04安装配置TensorFlow GPU版本
之前摸爬滚打总是各种坑,今天参考这篇文章终于解决了,甚是鸡冻\(≧▽≦)/,电脑不知道怎么的,安装不了16.04,就安装15.10再升级到16.04 requirements: Ubuntu 16.0 ...
- Ubuntu 16.04下配置 Nginx 与 Node.js 以及服务的部署
第一步:安装nginx sudo apt-get update sudo apt-get install nginx 如果遇到依赖问题,尝试执行sudo apt-get -f install命令 第二 ...
- VMware 15安装Ubuntu 16.04并配置环境
VMware(虚拟机)是指通过软件模拟的具有完整硬件系统功能的.运行在一个完全隔离环境中的完整计算机系统,它能在Windows系统上虚拟出多个计算机,每个虚拟计算机可以独立运行,可安装各种软件与应用等 ...
- Ubuntu 16.04 orb-slam2配置
说明:Ubuntu 16.04以及必要的基础软件安装完成之后进行: 1.OpenNI2安装(可选) 安装依赖项: sudo apt--dev freeglut3-dev doxygen graphvi ...
- Ubuntu 16.04简单配置备忘录
1.几个安装包的地址 1.Linux QQ:https://im.qq.com/linuxqq/index.html 2.网易云音乐:http://s1.music.126.net/download/ ...
随机推荐
- 22 SHELL 获取当前路径
常见的一种误区,是使用 pwd 命令,该命令的作用是"print name of current/working directory",这才是此命令的真实含义,当前的工作目录,这里 ...
- Scala(五)【集合的高级使用】
目录 一.集合属性 size length contains mkString 二.集合方法 drop.dropRight distinct:去重 head.last:获取第一个.最后一个元素 tai ...
- 我在项目中是这样配置Vue的
启用压缩,让页面加载更快 在我们开发的时候,为了方便调试,我们需要使用源码进行调试,但在生产环境,我们追求的更多的是加载更快,体验更好,这时候我们会将代码中的空格注释去掉,对代码进行混淆压缩,只为了让 ...
- Oracle—表、约束、索引、表空间、分区、序列、统计信息
表.约束.索引.表空间.分区.序列.统计信息 一.表及其操作 1.创建表 create table 表名 ( 字段名1 字段类型 默认值 是否为空 , 字段名2 字段类型 默认值 是否为空, 字段名3 ...
- 转 Android 多线程:手把手教你使用AsyncTask
转自:https://www.jianshu.com/p/ee1342fcf5e7 前言 多线程的应用在Android开发中是非常常见的,常用方法主要有: 继承Thread类 实现Runnable接口 ...
- tomcat 之 httpd session stiky
# 注释中心主机 [root@nginx ~]# vim /etc/httpd/conf/httpd.conf #DocumentRoot "/var/www/html" #:配置 ...
- maven的lifecycle
1.maven clean. 清理项目的target目录 2.maven compile 编译项目 3.maven test 编译项目后,再执行Junit测试方法 4.maven package 编译 ...
- Spring Boot中使用Mybatis
一.步骤 导入依赖:MySQL驱动.Druid依赖.MyBatis与Spring Boot整合依赖.Lombok依赖 在Service接口实现类上添加@Service注解 在Dao接口上添加@Mapp ...
- Spring Boot下使用JSP页面
一.创建webapp目录 在src/main下创建webapp目录,用于存放jsp文件.这就是一个普通的目录,无需执行Mark Directory As 二.创建jsp 1.指定web资源目录 在sp ...
- 远程连接mysql库问题
如果你想连接你的mysql的时候发生这个错误: ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL serve ...