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

- Embedded Linux to solve the problem in the time zone (Linux)

- Linux LVM space expansion Demo (Linux)

- How to customize your Linux desktop: Gnome 3 (Linux)

- Simple to use Linux GPG (Linux)

- Oracle 12c In-Memory Study (Database)

- Use Oracle 11g show spparameter command (Database)

- Linux Learning --- disk partition / relational representation + mount (Linux)

- SQL in the specific internal Oracle process (Database)

- Android in the coordinate system and a method to obtain the coordinates (Programming)

- AWR Report (Database)

- DataGuard Standby backup error RMAN-06820 ORA-17629 to solve (Database)

- Linux System Administrator common interview questions and answers 30 (Linux)

- Based on Google Cloud Storage Mirroring open Maven Central Repository (Server)

- Present Situation and Development Trend of firewall products (Linux)

- Let you Fun Ubuntu desktop eleven weapon (Linux)

- Https (SSL / TLS) Detailed principles (Server)

- Zabbix monitoring different versions of RAID installation and monitoring and MySQL master-slave monitor (Server)

- ORA-14400: inserted partition key does not map to any partition (Database)

- Java look and feel mode (Facade mode) (Programming)

  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: