伺服器實踐001 -- cento7 伺服器環境搭建
阿新 • • 發佈:2019-01-01
配置python環境工具
centos 7 自帶python2.7.5版本,但是沒有pip工具,所以我們首先要安裝pip工具,然後在這個基礎上一步步搭建python的web開發環境。
編譯安裝pip
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 # 檢視安裝是否成功
編譯安裝 setuptools
cd /usr/local/src wget https://pypi.python.org/packages/6c/54/f7e9cea6897636a04e74c3954f0d8335cc38f7d01e27eec98026b049a300/setuptools-38.5.1.zip#md5=1705ae74b04d1637f604c336bb565720 yum install zip yum install unzip 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 儲存退出即可
安裝git
yum install git
shell 顯示git狀態
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='[\ [email protected]\h \W$(__git_ps1 " (%s)")]$ '
source /etc/profile
安裝 virtualenv virtualenvwrapper
pip install virtualenv virtualenvwrapper
# 配置環境變數
vi /etc/profile
# 輸入下列程式碼:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/workspace
source /usr/bin/virtualenvwrapper.sh
# 儲存退出:
source /etc/profile
安裝gunicorn
pip install gunicorn
安裝 supervisor
pip install supervisor
supervisor 配置修改
配置python3 環境變數
安裝 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/
# 首先建立 python3 資料夾
./configure --prefix=/usr/local/python3
yum -y install zlib*
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