Build a Django + Flup + Nginx environment in Ubuntu

Source: Internet
Author: User
Tags install openssl install django
First, we must understand the role of these three in this environment. 1. nginx :( "enginex") is a high-performance HTTP and reverse proxy server, which works similar to apache. It can process some static file requests. For dynamic file requests, it can distribute requests to different dynamic languages through fastcgi. 2. flup: it is a web server software written in python. It can accept requests from nginx and execute the corresponding pyth

First, we must understand the role of these three in this environment.

1. nginx :( "engine x") is a high-performance HTTP and reverse proxy server, which works similar to apache. It can process some static file requests. For dynamic file requests, it can distribute requests to different dynamic languages through fastcgi.

2. flup: it is a web server software written in python. It can accept requests from nginx, execute the corresponding python code, and return the results to nginx.

3. django: a python-based web framework. It can be used for basic things, such as cookie, session management, template mechanism, and permission management.

Before setting up the environment, you must install the python environment. This article uses python2.6.5. The installation of python is not described here.

1. Install related support files
Setuptools: setuptools is required to install the python class library through setup. py.

Wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
Sh setuptools-0.6c11-py2.6.eggpcre, regular expression-related class libraries, ow.ssh, nginx installation required.

Wget http://sourceforge.net/projects/pcre/files/pcre/8.02/pcre-8.02.tar.gz/download
Tar zxvf pcre-8.02.tar.gz
Cd pcre-8.02
./Configure
Make
Make install
Cd ..
Apt-get install openssl libssl-develzlib, which is required by many software libraries.

Wget http://downloads.sourceforge.net/project/libpng/zlib/1.2.5/zlib-1.2.5.tar.gz? Use_mirror = nchc
Tar zxvf zlib-1.2.5.tar.gz
Cd zlib-1.2.5
./Configure
Make
Make install
Cd .. 2. Install django
Wget http://www.djangoproject.com/download/1.2.1/tarball/
Tar zxvf Django-1.2.1.tar.gz
Cd Django-1.2.1
Python setup. py install
Cd .. If you need to use mysql data, you can refer to install Django1.2 and Mysql-Python in Linux.

3. Install flup
Wget http://www.saddi.com/software/flup/dist/flup-1.0.2.tar.gz
Tar zxvf flup-1.0.2.tar.gz
Cd flup-1.0.2
Python setup. py install
Cd .. 4. Install nginx
Wget http://nginx.org/download/nginx-0.8.39.tar.gz
Tar zxvf nginx-0.8.39.tar.gz
Cd nginx-0.8.39
./Configure
Make
Make instll Note: After installation, a Configuration summary message is displayed, which can be saved and [LINUX community www.LinuxIDC.com] can be used later.

5. Configuration
Configure flup and flup to communicate through fastcgi. Add the following configuration in the location {..} configuration section of the server {...} running python program:

Fastcgi_pass unix:/tmp/mysite. sock;
Fastcgi_param PATH_INFO $ fastcgi_script_name;
Fastcgi_param REQUEST_METHOD $ request_method;
Fastcgi_param QUERY_STRING $ query_string;
Fastcgi_param CONTENT_TYPE $ content_type;
Fastcgi_param CONTENT_LENGTH $ content_length;
Fastcgi_pass_header Authorization;
Fastcgi_intercept_errors off;
Fastcgi_param SERVER_PROTOCOL $ server_protocol;
Fastcgi_param SERVER_PORT $ server_port;
Fastcgi_param SERVER_NAME $ server_name; 6. Run
Create a django Project

Cd ~
Django-admin.py startproject mysite run django in cgi Mode

~ /News/manage. py runfcgi daemonize = true socket =/tmp/mysite. sock start nginx

/Usr/local/nginx/sbin/nginx


Enjoy the fun of django!

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.