Reference: http://jupyter.readthedocs.org/en/latest/install.html
如果安装了anaconda,则可以使用如下操作安装:
conda update jupyter
如果没有,则使用pip安装:
pip install jupyter
创建用户用作运行jupyter:
addusr ipython
编辑/etc/sudoers,并将其加入sudo用户组。
ipython ALL=(ALL) ALL
编辑/usr/lib/systemd/system/ipython-notebook.service,然后根据自己的要求进行配置,比如–ip=0.0.0.0表示允许外网访问:
[Unit]
Description=IPython notebook
[Service]
Type=simple
PIDFile=/var/run/ipython-notebook.pid
ExecStart=/usr/local/anaconda2/bin/jupyter notebook --ip=0.0.0.0 --no-browser
User=ipython
Group=ipython
WorkingDirectory=/home/ipython/notebooks
[Install]
WantedBy=multi-user.target
然后重载deamon并运行服务:
systemctl daemon-reload
systemctl enable ipython-notebook
systemctl start ipython-notebook
这样即在后台运行jupyter notebook服务了:
[root@centos7 ~]# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:8787 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN
由于想使用外网接入,因此需要在iptables里面打开端口8888,否则便会connection refused:
iptables -A IN_public_allow -p tcp -m tcp --dport 8888 -m conntrack --ctstate NEW -j ACCEPT