Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ Build Nginx + uWSGI + Flask operating environment under CentOS 6.4 tutorial     - Shell Programming Regular Expressions (Programming)

- 256 with rich colors decorate your terminal (Linux)

- Android Studio simple setup (Linux)

- Ubuntu 14.04 configure JDK1.8.0_25, switchable version (Linux)

- Configuring Allatori code confusion when developing general Java applications in NetBeans (Programming)

- Linux Getting Started tutorial: hard disk partition and to deal with traps (Linux)

- Linux log management tools Logrotate (Linux)

- Linux Apache server configure to protect system security (Linux)

- 10 Best Swift Tutorial examples (Programming)

- GitLab Guide installation under Ubuntu 14.04 (Server)

- Linux System Getting Started Learning: In RedHat Linux driver compiled Ixgbe (Linux)

- C # using the HttpClient Note: Preheat the long connection (Programming)

- Sudo and Root Account in Ubuntu related (Linux)

- Define and modify strings principle in Python (Programming)

- The most concise Systemd tutorial, just ten minutes (Linux)

- Linux some lessons learned about network security (Linux)

- Oracle database NUMBER (x, y) data types (Database)

- C ++ casts New Standard Comments (Programming)

- The most concise explanation of JavaScript closures (Programming)

- MySQL combination Git achieve differential backups can be used in the production environment (Database)

  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: