Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ Build Nginx + uWSGI + Flask operating environment under CentOS 6.4 tutorial     - Ubuntu simple method to track multiple time zones (Linux)

- Ubuntu Eclipse configuration Gtk + 2.0 libraries (Linux)

- Make full use of the Raspberry Pi SD card space (Linux)

- Python basis: os module on the file / directory using methods commonly used functions (Programming)

- Linux Crontab Timing task command Detailed (Linux)

- View processes and threads under Linux (Linux)

- impdp error ORA-31631, ORA-39122 (Database)

- Loop arrays in C language is not easy to find a bug (Programming)

- Docker - for the development and deployment of unified lightweight Linux containers (Linux)

- MongoDB 3.2 Cluster Setup (Database)

- CentOS 7.1 install NTFS-3G (Linux)

- Sorting Algorithm (1) Quick Sort C ++ implementation (Programming)

- Python-- for anomalies and reflection of objects articles (Programming)

- 11.2.04 Oracle RAC directory crfclust.bdb file is too large, Bug 20186278 (Database)

- The YUM package management under Linux (Linux)

- Linux5 install MySQL 5.6 (RPM mode) (Database)

- CentOS7 management of systemd (Linux)

- Configuring DNS process under CentOS 6.5 (Server)

- CentOS 6 Install Linux kernel source (Linux)

- OpenCV 3.0 + Python 2.7 installation and testing under Ubuntu 14.04 (Linux)

  Build Nginx + uWSGI + Flask operating environment under CentOS 6.4 tutorial
  Add Date : 2018-11-21      
  Write down the build Nginx + uWSGI + Flask operating environment tutorial, author CentOS 6.4 actual configuration succeeded in CentOS 6.4, the record up for your reference, there are questions you can contact me.
1, install nginx

First install Before you install nginx gcc compilers and related tools, use yum to install, very convenient.

$ Sudo yum -y install gcc gcc-c ++ make autoconf automake

nginx Some modules require a third-party library support, such as gzip need zlib, rewrite module requires pcre library, ssl feature requires openssl library. Yum install directly on the line.

$ Sudo yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

The latest version of the official website to the nginx nginx.org download, I downloaded version 1.2.7 of.

$ Wget http://nginx.org/download/nginx-1.2.7.tar.gz

Extracting installation

$ Tar -zxv -f nginx-1.2.7.tar.gz

$ Cd nginx-1.2.7

$ ./configure

$ Make

$ Sudo make install

Here are the default parameters configure to use, can be modified according to their needs. You can use ./configure -help Show help instructions.

Start nginx server

sudo / usr / local / nginx / sbin / nginx -c /usr/local/nginx/conf/nginx.conf

Where / usr / local / nginx / sbin / nginx start the program represented here by the full path more intuitive, soft links can do according to their own habits to the system path.

Use a browser to access, if you see the Welcome to nginx! Message, it means that the installation was successful.

2, the installation uwsgi

First installation of dependencies python-devel, setuptools, libxml2-devel, directly yum install. If you are self-compiled and installed python, you can not install the python-devel.

$ Sudo yum -y install python-devel python-setuptools libxml2-devel

Net official website http://projects.unbit.it/uwsgi/ download uwsgi, although the pages are in English, but it is not difficult to find a page to download.

$ Wget http://projects.unbit.it/downloads/uwsgi-1.9.tar.gz

Extract the installation:

$ Tar -zxv -f uwsgi-1.9.tar.gz

$ Cd uwsgi-1.9

$ Python setup.py install
3, installation flask

Go to the official website to download http://flask.pocoo.org/ flask.

$ Wget http://pypi.python.org/packages/source/F/Flask/Flask-0.9.tar.gz

Extracting installation

$ Tar -zxv -f Flask-0.9.tar.gz

$ Cd Flask-0.9

$ Sudo python setup.py install

New flask project, a program file app.py, reads as follows:

from flask import Flask
app = Flask (__ name__)
@ App.route ( "/")
def hello ():
return "Hello World!"
if __name__ == "__main__":
app.run ()
Ensure flask with built-in web server to run.

4, configure nginx and uwsgi

This step is too much trouble, but it is not difficult to understand after principle.

uwsgi in nginx 1.2.7 is a standard module, so no need to install. Edit the nginx configuration file to load uwsgi.

location / {
    include uwsgi_params;
    root html;
    index index.html index.htm;

Are After editing the configuration file can be tested under no errors.

$ Sudo / usr / local / nginx / sbin / nginx -t -c /usr/local/nginx/conf/nginx.conf

After configuration is complete, restart nginx. First find nginx main process ID:

$ Ps -ef | grep nginx

The author is 13367 computer, and then restart

$ Sudo kill -HUP 13367

Under the new project a flask profile app_config.xml, the relevant parameters used to set uwsgi, one would need to specify uwsgi at startup configuration file, as follows: