yznnnn

【阿里云服务器】ECS轻量服务器 Centos 远程 JupyterNotebook 配置


1、购买服务器

阿里云的官方网站为:https://www.aliyun.com/

里面有各种套餐,学生建议购买学生云,大概9元每月。

这里使用的是 centos 服务器

2、修改主机名

  第一次通过浏览器连接会发现用户名是一堆乱码,首先修改root密码:

# sudo passwd
_______________________________________________________
admin@iZwz954fergdge453fe29tdZ:~$ sudo passwd
sudo: unable to resolve host iZwz954fergdge453fe29tdZ
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

  然后修改主机名,然后重启:

# su
# vim /etc/hostname 
# reboot

3、初始设定

  root用户下,美化一下终端

# vim /etc/profile
_______________________________________________________
# 在最后加入
PS1=\'\[\033[1;31;1m\]\u:\[\033[1;32;1m\]\W\[\033[1;33;1m\]\$\[\033[1;37;1m\]\'
_______________________________________________________
# source /etc/profile

  将软件源修改为阿里源

# 操作步骤 
# cd /etc/yum.repos.d # 进入yum文件夹 
# mv CentOS-Base.repo CentOS-Base.repo.bak # 备份原文件 
# wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # 下载阿里源的文件 
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 


# yum clean all		# 清理缓存
# yum makecache	# 重新生成缓存
# yum update 		# 更新

  安装一些基本依赖:

# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++  openssl-devel

  vim 显示行号

# vim /etc/vimrc
________________
set number

4、建立专门用户用于 JupyterNotebook

先建立一个新用户,专门用来登录 JupyterNotebook

# adduser jupyter
# passwd jupyter
# su jupyter

终端美化

# vim ~/.bash_profile 
_______________________________________________________
# 在最后加入
PS1=\'\[\033[1;31;1m\]\u:\[\033[1;32;1m\]\W\[\033[1;33;1m\]\$\[\033[1;37;1m\]\'
_______________________________________________________
# source ~/.bash_profile 

建立两个文件夹

mkdir ~/software
mkdir ~/download
mkdir ~/JupyterNotebookProject

4、安装 Python

  进入用户jupyter,先编译安装:

# mkdir ~/software/python
# wget -P ~/download https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
# mkdir ~/software/python/python36
# tar -zxvf ~/download/Python-3.6.8.tgz -C ~/download
# cd ~/download/Python-3.6.8
# ./configure --prefix=\'/home/jupyter/software/python/python36\' --with-ssl
# make
# make install


  配置环境变量

# vim ~/.bash_profile 
_______________________________________________________
# 在最后加入
PATH=$PATH:/home/jupyter/software/python/python36/bin  #路径名跟自己实际情况而定
export PATH
_______________________________________________________
# source ~/.bash_profile 

  查看下 ssl 模块能否成功导入,要保证成功导入!

安装一些重要的包(由于前面已经切换了阿里源,所有可以不用附加源):

pip3.6 install scipy -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip3.6 install matplotlib -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip3.6 install pandas -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip3.6 install sklearn -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip3.6 install tensorflow -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip3.6 install jupyter -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com



安装 jupyter 插件

pip3.6 install jupyter_contrib_nbextensions -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
	
jupyter contrib nbextension install --user

pip3.6 install jupyter_nbextensions_configurator -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

5、配置 JupyterNotebook 远程连接

在Jupyter用户下生成登录密码:

# jupyter notebook --generate-config
# jupyter notebook password
-------------------------------
[NotebookPasswordApp] Wrote hashed password to /home/jupyter/.jupyter/jupyter_notebook_config.json

修改配置文件

# mkdir
# vim ~/.jupyter/jupyter_notebook_config.py
---------------------------------
# 加入如下内容
c.NotebookApp.ip=\'*\' 
c.NotebookApp.open_browser = False 
c.NotebookApp.port =8888
nohup jupyter-notebook --ip=0.0.0.0 --allow-root &

6、安装插件

pip3.6 install jupyter_contrib_nbextensions -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
	
jupyter contrib nbextension install --user

pip3.6 install jupyter_nbextensions_configurator -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

分类:

技术点:

相关文章:

  • 2021-11-14
  • 2021-10-14
  • 2021-09-20
  • 2021-11-04
  • 2021-08-14
  • 2022-12-23
  • 2021-12-15
  • 2021-11-25
猜你喜欢
  • 2021-11-29
  • 2021-11-14
  • 2022-12-23
  • 2021-11-04
  • 2021-09-19
  • 2021-12-04
  • 2021-06-04
相关资源
相似解决方案