CentOS6.7 Deploying a Python Web environment

Source: Internet
Author: User
Tags virtual environment

Install the underlying compilation environment

Yum Install wget gcc make-y

Download the source package on the Python website

wget HTTPS://WWW.PYTHON.ORG/FTP/PYTHON/3.6.2/PYTHON-3.6.2.TAR.XZ

Unpack, unzip

xz-d PYTHON-3.6.2.TAR.XZTAR-XVF Python-3.6.2.tar

Install environment Dependent packages

Yum install zlib-devel readline-devel ncurses-devel sqlite-devel gdbm-devel xz-devel tk-devel openssl-devel-y

Compile

CD Python-3.6.2./configure--prefix=/usr/local/python3.6--enable-optimizations

--enable-optimizations is an optimization option (LTO,PGO, etc.) with this flag compiled, performance has about 10% optimization, but this will significantly increase the compilation time.

Configuring Environment variables

Ln-s/usr/local/python3.6/bin/python3/usr/bin/python3

Enter Python3 to see if the configuration was successful


After the Python3.4 version comes with a virtual environment, you can create a virtual environment directly using the following command

Python3-m venv MIM/Project Catalogue
Source Mim/bin/activate into Virtual environment

You can use the Deactivate command to exit the virtual environment


Installing the Python flask Framework

Flask is a lightweight web framework that needs to be switched to a virtual environment because flask requires multiple extensions to avoid affecting the default Python environment files

Pip Install flask

After the installation is complete, you can write a small program to test whether the flask was successfully installed

VI hello.py
From flask Import Flaskapp = Flask (__name__) @app. Route ("/") def hello (): return "Hello world!" if __name__ = "__mai N__ ": App.run ()

Start flask

Python hello.py* Running on http://127.0.0.1:5000/(press CTRL + C to quit)

Installing Gunicorn

In the production environment, the flask comes with a limited server function, can not meet the performance requirements, the use of Gunicorn do WSGI containers, the deployment of Python programs

Pip Install Gunicorn

After installation, you can start the flask with Gunicorn

gunicorn-w4-b0.0.0.0:8000 Hello:app

-W Indicates how many workers are turned on

-B indicates the access address of the Gunicorn

: followed by service access port number


Know-how Office, professional mobile office platform https://zx.naton.cn/
"Director" 12 Spring and Autumn,[email protected];
"Master" Zelo,[email protected];
"Operation" Wolf World,[email protected];
"Product design" stray cats,[email protected];
"Experience Design",[email protected];
"IOS" Amoy code handyman,[email protected]; imcg33k,[email protected];
"Android", the ape-lay,[email protected]; an epiphany of thought,[email protected];
"Java" Chief engineer Mr_w,[email protected];
"Test" the Earth Mirror asked,[email protected];
"Data" is much more joyful,[email protected];
"Security" is confidential, you know.




This article is from the "practitioner" blog, so please keep this source http://bluemooder.blog.51cto.com/12822812/1955216

CentOS6.7 Deploying a Python Web environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.