1> 下载Anaconda
wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
wget https://mirrors.condor.vip/anaconda/Anaconda3-2021.11-Linux-x86_64.sh # 国内
2> 安装Anaconda
bash Anaconda3-2021.11-Linux-x86_64.sh
3> 配置jupyter
① 设置密码
source ~/.bashrc
ipython # 进入ipython界面
from notebook.auth import passwd
passwd() # 记录sha1后面的密码
exit()
② 修改config文件
jupyter notebook --generate-config
vim /root/.jupyter/jupyter_notebook_config.py # 在文件的最后增加下面的配置文件
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'passwd'
c.NotebookApp.open_browser = False
c.NotebookApp.allow_remote_access = True
c.NotebookApp.allow_root = True
c.NotebookApp.port = 2010
c.NotebookApp.notebook_dir = '/data/jupyter'
③ 在云服务器安全组中开放上面设置的端口号
vim /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 2010 -j ACCEPT
systemctl restart iptables
④ 开启jupyter服务
jupyter notebook --ip=0.0.0.0 --no-browser --allow-root # 终端运行
nohup jupyter notebook --allow-root > jupyter.log 2>&1 & # 后台运行
4> jupyter开机自启动
vim /lib/systemd/system/jupyter.service
[Unit]
Description=jupyter notebook
After=network.target
[Service]
Tpye=forking
EnvironmentFile=/usr/local/anaconda3/bin/jupyter-notebook
ExecStart=/usr/local/anaconda3/bin/jupyter-notebook
ExecStop=/usr/bin/pkill jupyter-notebook
KillMode=process
Restart=on-failure
RestartSec=30s
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable jupyter.service
sudo systemctl start jupyter.service
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END