1.安装pcre,pcre是一个轻量级的正则表达式函数库,nginx的HTTP Rewrite模块会用到。

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gztar -zxvf pcre-8.34.tar.gzcd pcre-8.34./configuremake && make install

2.安装nginx.

wget http://nginx.org/download/nginx-1.5.9.tar.gztar -zxvf nginx-1.5.9.tar.gzcd nginx-1.5.9./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-cc-opt='-O3' --with-cpu-opt=opteronmake && make install

3.安装MySQL-python.

yum install MySQL-python -y     #yum安装方式wget http://nchc.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gztar -zxvf MySQL-python-1.2.2.tar.gzcd MySQL-python-1.2.2python setup.py install

4.安装uwsgi.

wget http://projects.unbit.it/downloads/uwsgi-2.0.4.tar.gztar -zxvf uwsgi-2.0.4.tar.gzcd uwsgi-2.0.4makecp uwsgi /usr/bin

5.安装Django.

wget htpp://www.djangoproject.com/m/releases/1.4/Django-1.4.9.tar.gztar -zxvf Django-1.4.9.tar.gzcd Django-1.4.9python setup.py install

6.配置nginx。修改/usr/local/nginx/conf/nginx.conf,添加以下server域配置:

    server {        listen       80;        server_name  www.omserver.com;        location / {            uwsgi_pass 192.168.202.128:9000;            include uwsgi_params;            uwsgi_param UWSGI_CHDIR /data/www/OMserverweb;  #项目主目录            uwsgi_param UWSGI_SCRIPT django_wsgi;            access_log off;        }        location ^~ /static {            root /data/www/OMserverweb;        }        location ~* ^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg)$ {            root /data/www/OMserverweb/static;            access_log off;        }    }

7.配置uwsgi。创建uwsgi配置文件/usr/local/nginx/conf/uwsgi.ini

[uwsgi]socket = 0.0.0.0:9000master = truepidfile = /usr/local/nginx/uwsgi.pidprocesses = 8chdir = /data/www/OMserverwebpythonpath = /data/wwwprofiler = truememory-report=trueenable-threads=truelogdate=truelimit-as=6048daemonize=/data/logs/django.log

8.启动uwsgi和nginx服务。

/usr/bin/uwsgi --ini /usr/local/nginx/conf/uwsgi.ini/usr/local/nginx/sbin/nginx

9.创建django项目

cd /data/www/django-admin.py startproject OMserverweb

最后访问出现django欢迎界面表示配置成功。