使用环境工具php
python 环境工具 python 2.7.5 # python2版本,系统自带 pip 9.0.1 # python2版本的pip,python工具集,编译安装 virtualenv 15.1.0 # python2版本虚拟环境依赖,pip安装 virtualenvwrapper 4.8.2 # 配合virtualenvwrapper使用,pip安装 setuptools 38.5.1 # python工具集,编译安装 gunicorn 19.7.1 # python的wsgi服务器,pip安装 supervisor 3.3.4 # python进程管理工具,pip安装 python3 环境工具 python3 3.6.4 # python3版本,编译安装 pip 9.0.1 # 安装python3版本自带,区别于python2环境下的pip setuptools 28.8.0 # 安装python3版本自带 gunicorn 19.7.1 # python的wsgi服务器,pip安装 其余工具 git 1.8.3.1 # 著名软件托管平台
简单说明python
CentOS 7.2服务器自带python2.7.5版本,惋惜没有pip工具,因此咱们须要先安装 pip工具,而后在此基础上一步步搭建python的web开发环境
编译安装pipmysql
cd /usr/local/src wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9 tar -zxvf pip-9.0.1.tar.gz cd pip-9.0.1/ python setup.py build python setup.py install pip -V # 查看安装是否成功
编译安装setuptoolsnginx
cd /usr/local/src wget https://pypi.python.org/packages/6c/54/f7e9cea6897636a04e74c3954f0d8335cc38f7d01e27eec98026b049a300/setuptools-38.5.1.zip#md5=1705ae74b04d1637f604c336bb565720 yum install zip # 已经安装的同窗跳过这步 unzip setuptools-38.5.1.zip cd setuptools-38.5.1 python setup.py build python setup.py install pip list # 查看setuptools是否安装成功 备注:若是执行pip list命令时出现 DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. 错误,解决方法以下: vi /root/.pip/pip.conf 输入: [list] format=columns 保存退出便可
安装gitgit
yum install git 关于git的基本操做我就不在这里叙述了,最后我会放一篇资料提供给你们参考
shell显示git状态github
vi /etc/profile # 插入下方代码 source /usr/share/doc/git-1.8.3.1/contrib/completion/git-completion.bash source /usr/share/doc/git-1.8.3.1/contrib/completion/git-prompt.sh export GIT_PS1_SHOWDIRTYSTATE=1 export GIT_PS1_SHOWSTASHSTATE=1 export GIT_PS1_SHOWUNTRACKEDFILES=1 export GIT_PS1_SHOWUPSTREAM="verbose git svn" PS1='[\u@\h \W$(__git_ps1 " (%s)")]$ ' source /etc/profile
安装virtualenv virtualenvwrapperweb
pip install virtualenv virtualenvwrapper # 配置环境变量 vi /etc/profile # 输入下列代码: export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/workspace source /usr/local/bin/virtualenvwrapper.sh # 保存退出: source /etc/profile
安装gunicornsql
pip install gunicorn
安装supervisorshell
pip install supervisor
supervisor配置修改segmentfault
cd /etc/ mkdir supervisor cd supervisor mkdir conf.d echo_supervisord_conf vi supervisord.conf # 修改配置以下:
# 保存退出 # 开启supervisord supervisord -c /etc/supervisor/supervisord.conf ps aux|grep supervisord
# 启动成功 # 在浏览器使用域名:9001,输入设置的帐号,密码结果以下
# 不用在乎上面的blog项目,下一章会讲
配置supervisor开机启动
cd /lib/systemd/system/ touch supervisord.service #加入下列代码: # supervisord service for systemd (CentOS 7.0+) # by ET-CS (https://github.com/ET-CS) [Unit] Description=Supervisor daemon [Service] Type=forking ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown ExecReload=/usr/bin/supervisorctl $OPTIONS reload KillMode=process Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target # 保存退出 # 尝试以下命令 systemctl stop supervisord.service systemctl start supervisord.service systemctl restart supervisord.service
环境安装结果以下
安装python3
cd /usr/local/src wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz tar -zxvf Python-3.6.4.tgz cd Python-3.6.4/ ./configure --prefix=/usr/local/python3 make && make install 安装成功 python3安装自带pip和setuptools
配置python3环境变量
vi /etc/profile export PATH=$PATH:$HOME/bin:/usr/local/python3/bin source /etc/profile
安装gunicorn
pip3 install gunicorn
环境安装结果以下