Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Build Nginx + uWSGI + Flask operating environment under CentOS 6.4 tutorial     - Oracle 11g dataguard main library backup and recovery to the test environment in one database error (Database)

- Install Linux Mint 17: 20 things to do (Linux)

- Oracle 11g user rights management study notes (Database)

- Let Git variety of colors and custom log format output (Linux)

- MySQL 5.7 can not log in problem (Database)

- SSL VPN SSL VPN access to security websites patron (Linux)

- Android Sets the system screen brightness (Programming)

- To_explore Linux system boot process (Linux)

- How to modify the Sublime in Tab four spaces (Linux)

- Vi (Vim) keyboard map and its basic commands (Linux)

- Linux Getting Started tutorial: Experience Xen Virtual Machine chapter (Linux)

- Nginx configuration support f4v video format player (Server)

- Actual SSH port forwarding (Linux)

- Use the TC flow control test under Linux (Linux)

- According to the national position on how to block traffic in Linux (Server)

- Orionode source Linux Mint installation (Linux)

- Terminal Linux command prints - echo (Linux)

- Zabbix installation under Linux (Server)

- Java NIO The Glob mode Detailed (Programming)

- Get the Linux device PCI ID method (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 http://127.0.0.1/, 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;
    uwsgi_pass 127.0.0.1:3031;
    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: