CentOS + Nginx + uWSGI + Python multi-site environment construction

Source: Internet
Author: User

Environment:

CentOS X64 6.4

Nginx 1.5.6

Python 2.7.5

Body:

I. Install the required class library and Python2.7.5

Install necessary Development Kits

yum groupinstall "Development tools"yum install zlib-devel bzip2-devel pcre-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

CentOS comes with Python2.6.6, but we can install Python2.7.5 again:

cd ~wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2tar xvf Python-2.7.5.tar.bz2cd Python-2.7.5./configure --prefix=/usr/localmake && make altinstall

After installation, run the "python2.7" command to enter the python2.7 environment.

Ii. Install Python package management

Easy_install package https://pypi.python.org/pypi/distribute

Easy installation of Python Development Kits

cd ~wget https://pypi.python.org/packages/source/d/distribute/distribute-0.6.49.tar.gztar xf distribute-0.6.49.tar.gzcd distribute-0.6.49python2.7 setup.py installeasy_install --version

The red part must be "python2.7"; otherwise, it will be installed in the default 2.6 environment.

Pip pack https://pypi.python.org/pypi/pip

The advantage of installing pip is that you can manage Python packages using pip list and pip uninstall. easy_install does not have this function and only supports uninstall.

easy_install pippip --version
3. Install uwsgi

Uwsgi: https://pypi.python.org/pypi/uWSGI

Uwsgi Parameter Details: http://uwsgi-docs.readthedocs.org/en/latest/Options.html

pip install uwsgiuwsgi --version

Test whether uwsgi is normal:

Create a test. py file with the following content:

def application(env, start_response):        start_response('200 OK', [('Content-Type','text/html')])        return "Hello World"

Then run on the terminal:

uwsgi --http :8001 --wsgi-file test.py

Enter http: // 127.0.0.1: 8001 in the browser to check whether "Hello World" output exists. If no output is available, check your installation process.

4. Install django
pip install django

Run the following command to test whether django is normal:

django-admin.py startproject demositecd demositepython2.7 manage.py runserver 0.0.0.0:8002

Enter http: // 127.0.0.1: 8002 in the browser to check if django is running normally.

5. Install nginx
cd ~wget http://nginx.org/download/nginx-1.5.6.tar.gztar xf nginx-1.5.6.tar.gzcd nginx-1.5.6./configure --prefix=/usr/local/nginx-1.5.6 \--with-http_stub_status_module \--with-http_gzip_static_modulemake && make install

Recommended reading:

You should use Nginx + uWSGI

UWSGI + Nginx deploy Flask Web Applications

Deployment of Django + Nginx + uWSGI

Deploy Python applications in Nginx + uWSGI in Linux

Install Nginx + uWSGI + Django on Ubuntu Server 12.04

CentOS 5.5 + Nginx 0.8.50 + uWSGI + Django 1.2.3 deploy the Django Project

Nginx details: click here
Nginx: click here

  • 1
  • 2
  • Next Page

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.