Transferred from: https://zhuanlan.zhihu.com/p/24554242
Step1. Install the most basic development tools and spit out any rubbish tutorials besides
# yum groupinstall "Development tools"# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel
Step2. Download code configure→make→make Altinstall
3.5.2 Download and install the following:
# cd /usr/local/src# wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz# tar -zxvf Python-3.4.3.tgz # cd Python-3.4.3# ./configure --prefix=/usr/local/python# make && make altinstall
Step3. Installing the Python3.4 Common Library
# echo "/usr/local/python/lib" >> /etc/ld.so.conf# ldconfig
Step4. Installing Python3.4 to/usr/local/bin/
# ln -s /usr/local/python/bin/python3.4 /usr/local/bin/python
Step5. Confirm that the installation is correct
# /usr/local/python/bin/python3.4 -V# python -V
Step6. Installing Easy_install
# cd /usr/local/src# wget https://pypi.python.org/packages/source/s/setuptools/setuptools-18.0.1.zip# unzip setuptools-18.0.1.zip# cd setuptools-18.0.1# /usr/local/bin/python setup.py install# ln -s /usr/local/python/bin/easy_install /usr/local/bin/easy_install
STEP7. Installing PIP
# /usr/local/bin/easy_install pip# ln -s /usr/local/python/bin/pip /usr/local/bin/pip
Step8. Installing virtualenv
# pip install virtualenv# ln -s /usr/local/python/bin/virtualenv /usr/local/bin/virtualenv
Step9. Installing Virtualenvwrapper
# pip install virtualenvwrapper
STEP10. Configuring Virtualenvwrapper parameter Settings
$ vim ~/.bashrcif [ -f /usr/local/python/bin/virtualenvwrapper.sh ]; thenexport WORKON_HOME=$HOME/.virtualenvssource /usr/local/python/bin/virtualenvwrapper.shfi
Supplemental Virtualenvwrapper Usage
1. Create an environment
mkvirtualenv env1mkvirtualenv env2
Once the environment is created, it automatically enters the directory and activates the environment.
2. Switching the environment
workon env1 # # (运行:ls ~/.virtualenvs 可见)workon env2
3. List existing environment
workon
4. Exit the Environment
deactivate
5. Deleting an environment
rmvirtualenv
6. Create Project
The project will be created into the Project_home directory, which is actually the equivalent of building an environment in a directory.
Supplemental Configuration Nginx
1. Download Nginx
yum install nginx
2. Start the Nginx service
systemctl start nginx
3. Configuration
The default configuration file under the/etc/nginx path, using this configuration has been able to properly run Nginx, if you need to customize, modify its nginx.conf and other files.
4. Testing
Enter the IP of the machine that deploys the NGINX environment in the browser address bar, and if everything is OK, you should see the following words.
5. List all port statuses
netstat -ntlp
With kill-9 PID
Supplemental Gunicorn Configuration
Gunicorn Green Unicorn is a Python WSGI Unix http server. This is a model of the Pre-fork worker, transplanted from Ruby's Unicorn (Unicorn) project. The Gunicorn server is roughly compatible with a variety of web frameworks, requiring very simple execution, lightweight resource consumption, and quite fast.
Gunicorn should be installed in virtualenv environment, remember to activate Workon before installation env1!
(venv) $ pip install gunicorn
Line up to run the Web:
(venv) $ gunicorn -w 4 -b 127.0.0.1:8080 wsgi:application
Note: The specific meaning of each parameter is believed to be found.
Supplemental Process Daemon
Supervisor Guardian God does not support PYTHON3,CENTOS7 does not support upstart, egg pain!
As of now, no solution has been found, but the systemd was accidentally harvested as a daemon protection routine for the python process.
About SYSTEMD's introduction and use of the following two blog posts recommended by Nanyi teacher, written in very detailed and comprehensive
- Command Chapter
- Practice Chapter
This article is written here, deployment is so, halfway will appear some bugs, you can certainly be the problem of the program, carefully check ha!
The language of glue is profound,
The Lord had only one or two to lead the new man,
Veteran can go to another column: Python Chinese community
Novice can refer to the history directory:
Python data analysis and visualization instance catalog
Centos7.2+python3x+flask Deploying Standardized configuration processes