Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Build Nginx + uWSGI + Flask operating environment under CentOS 6.4 tutorial     - Atheros AR8161 / AR8162 network card driver problem solving in CentOS 6.4 (Linux)

- Use Visual Studio 2015 to develop Android program (Programming)

- Do not enter password login ssh (Server)

- Installation GitLab appears ruby_block supervise_redis_sleep action run (Linux)

- HomeKit User Interface Guidelines (Linux)

- CentOS 6 / Linux su: Unable to set user ID: Resource temporarily unavailable (Linux)

- Create Your Own Docker base image in two ways (Linux)

- Talk about the Linux folder permissions issue again (Linux)

- Oracle conditional select statements and looping statements (Database)

- Hadoop 2.5 Pseudo distribution installation (Server)

- Ubuntu 14.04 jdk Installation and Configuration (Linux)

- Ubuntu How to install screen recording tool Simple Screen Recorder 0.3.1 (Linux)

- Shutdown - an advanced shutdown artifact (Linux)

- How to interactively create a Docker container (Server)

- ActiveMQ memory settings and flow control (Linux)

- Windows 8.1 and Ubuntu 14.04 dual system uninstall Ubuntu Tutorial (Linux)

- IOS interview questions Summary (Programming)

- OpenSUSE / Linux network configuration (Linux)

- Locale files under Ubuntu (Linux)

- Ordinary users how to use the firewall software (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: