Nginx + uwsgi + web. py build example

Source: Internet
Author: User

Simply put it bluntly, write down the detailed setup process for record.

(1) install nginx
1.1 download nginx-1.0.5.tar.gz and decompress
1.2./configure (you can also add -- prefix = path to specify the installation path)
In this case, you may be prompted that PCRE support is missing. To install PCRE, you can install PCRE-devel using Yum install PCRE-devel.
1.3 make
1.4 make install

(2) install uwsgi
2.1 Download uwsgi-0.9.8.2.tar.gz and decompress
2.2 make
When you install uwsgi, you may be prompted that libxml2 does not exist. In this case, we recommend that you use the yum install libxml2-devel to solve this problem.

(3) Install Web. py
You can use easy_install web. py to install the latest version. However, I encountered an error while installing 0.36, and it was a syntax error, so I finally rolled back to version 0.35.

(4) use a simple webpyProgramAs an example. BelowCodeIs a complete webpy Program (webpytest. py)

 
Import weburls = ('/(. *) ', 'Hello') APP = web. application (URLs, globals () Class Hello: def get (self, name): If not name: Name = "world" return "hello" + name + "! "Application = app. wsgifunc ()

The application = app. wsgifunc () in the last sentence is the key. In this case, you can access it through wsgi.

(5) Start uwsgi
Uwsgi-s 127.0.0.1: 9000-W webpytest

(6) Change nginx configuration (nginx. conf)

 
Server {Listen 80; SERVER_NAME 10.0.11.226; # charset koi8-r; # access_log logs/host. access. log main; Location/{include uwsgi_params; uwsgi_pass 127.0.0.1: 9000; uwsgi_param uwsgi_chdir/usr/local/sphinx; uwsgi_param uwsgi_script webpytest ;}

Note: The uwsgi_pass configuration must be consistent with that when uwsgi is started! Uwsgi_chdir refers to the directory where the program is located, and uwsgi_script refers to the program to be started (note that the py suffix must be removed here). Test results show that uwsgi_chdir and uwsgi_script can also be avoided!

(6) Start nginx
/Usr/local/nginx/sbin/nginx
Restart the nginx command to (/usr/local/nginx/sbin/nginx-s stop)

(7) access through HTTP
Http: // 10.0.11.226

The above is just a very simple setup process, only for record!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.