本地访问不了云服务器jupyter
Ubuntu 服务器安装jupyter,从本地访问
安装conda(miniforge3)
从国内镜像下载miniforge3
wget https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-26.1.0-0-Linux-x86_64.sh
chmod +x Miniforge3-26.1.0-0-Linux-x86_64.sh 赋予执行权限
bash Miniforge3-26.1.0-0-Linux-x86_64.sh 运行安装程序
按提示操作:
-
阅读许可协议(按空格翻页,输入
yes接受)。 -
选择安装路径(默认在
~/miniforge3,可自定义)。 -
是否初始化 Conda(通常选
yes,会自动将 conda 加入 PATH)。
source ~/.bashrc 安装完成后,执行以下命令使环境变量生效
验证安装 conda --version
sha256sum Miniforge3-26.1.0-0-Linux-x86_64.sh 校验文件完整性
创建新的环境,并安装jupyter
conda create -n d2l python=3.9 创建d2l环境 并指定python版本
conda activate d2l 激活环境 conda deactivate 退出环境
conda install jupyter notebook 安装jupyter
启动jupyter jupyter notebook
启动完成后,发现从本地浏览器无法访问jupyter
检查了华为云安全组规则,服务器端口8888是开通的
1:确认 Jupyter 是否已安装 which jupyter
2:jupyter notebook password ,后续访问输入密码,不用token
3:sudo ufw status 如果输出 Status: inactive,说明 Ubuntu 自带的防火墙确实已关闭,不会拦截任何流量
4:sudo iptables -L -n --line-numbers 检查 iptables 规则(底层防火墙)
所有链(INPUT、FORWARD、OUTPUT)的默认策略都是 ACCEPT(接受),不会拦截
5:测试连通性
telnet <你的服务器公网IP> 8888
6:ss -tulpn | grep 8888 确认 Jupyter 是否在监听
7:jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser
-
--ip=0.0.0.0:监听所有网络接口,使得可以从外部访问。 -
--port=8888:指定端口,你也可以换成其他未被占用的端口(如 8080)。 -
--no-browser:不在服务器上启动浏览器
如果希望后台运行(断开 SSH 后仍运行),可以使用 nohup
nohup jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser > jupyter.log 2>&1 &
启动后,查看日志或直接运行 ss -tulpn | grep 8888 确认 Jupyter 是否在监听
最后,可以在本地访问云服务器jupyter http://公网ip:8888
更多推荐
所有评论(0)