文章目录
yum
yum本地化
cd /etc/yum.repos.d; sudo mv CentOS-Base.repo CentOS-Base.repo.bak; wget -O /etc/yum.repos.d/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常见包的安装
包含 memcache, git, screen, wget, samba
yum -y install libevent-devel memcached git wget samba
python
文件下载
wget https://mirrors.huaweicloud.com/python/3.6.5/Python-3.6.5.tgz
安装
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel;mkdir -p /usr/local/python3;tar -zxvf Python-3.6.5.tgz;cd Python-3.6.5;./configure --prefix=/usr/local/python3;make;make install;ln -s /usr/local/python3/bin/python3 /usr/bin/python3;wget https://bootstrap.pypa.io/get-pip.py;python3 get-pip.py -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
配置环境变量
下列代码加入bashrc
alias runbash='source /root/.bashrc'
PATH=$PATH:/usr/local/python3/bin
mysql
pip
创建文件夹
mkdir /root/.pip && touch ~/.pip/pip.conf
配置文件
豆瓣
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
清华
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsing
阿里云
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
memcache
安装
上面的yum环节已经安装过了
启动,并设置为开机启动
memcached -d -m 10 -u root -l 127.0.0.1 -p 11211 -c 256 -P /tmp/memcached.pid
参数说明
-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,
-u是运行Memcache的用户,我这里是root,
-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址127.0.0.1
-p是设置Memcache监听的端口,我这里设置了11211,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid,
虚拟环境
安装
/usr/local/python3/bin/pip3 install virtualenv virtualenvwrapper
配置环境变量
找到文件夹的位置
which python3
whereis virtualenvwrapper
假如找到的python3 和 virtualenvwrapper如下
/usr/bin/python3/usr/local/python3
/bin/virtualenvwrapper.sh
则需要把下列配置写入bash
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/python3/bin/virtualenvwrapper.sh
创建虚拟环境
mkvirtualenv -p /usr/bin/python3 mecube
bash 常用命令
alias gitpull='git config user.name "zhuyewen";git config user.email "272944127@qq.com";git add .;git commit -m "save";git pull origin master'
alias cube='cd /root/django/mecube;workon mecube'
alias mands="cd /root/django/mands_2_0;workon mecube"
alias redomands='mands;rm -rf mands_2_0;mkdir mands_2_0;cd mands_2_0;git init;git config user.name "zhuyewen";git config user.email "272944127@qq.com";git checkout -b master;git remote add origin https://gitee.com/mands/mands_2_0.git;git pull https://gitee.com/mands/mands_2_0.git master'
alias runmands='python /root/django/mands_2_0/mands_2_0/manage.py runserver 0.0.0.0:14003'
alias runcube='cd /root/django/mecube;python manage.py runserver 0.0.0.0:8000'
alias runduty='sh /root/django/mecube/media/shell/cron_job.sh'
alias cubebc='cd /root/django/mecube/sql && mysqldump -uroot -pzhuyewen mecube > mysql.sql'
alias nginx='/usr/local/nginx/sbin/nginx'
alias newwindow='cube && cd ~ && screen -S django'
alias jupyter='jupyter notebook --allow-root'
JUPYTER
进入虚拟环境
workon mecube
安装 jupyter并生成配置文件
pip install jupyter;jupyter notebook --generate-config
进入 python,生成密码
python
from notebook.auth import passwd
passwd()
修改配置文件
# vi ~/.jupyter/jupyter_notebook_config.py
# 设置所有IP皆可访问
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.password = u'sha1:5f2d7589a1e4:0fbf4ea08554e6ce622b131946e8f9272d67ea2c'
# 禁止自动打开浏览器
c.NotebookApp.open_browser = False
# 服务端口
c.NotebookApp.port = 8080
启动服务
jupyter notebook --allow-root