debian 下安装 nginx + uWSGI

编译安装 nginx
sudo aptitude install gcc g++ libpcre3-dev libssl-dev

wget http://nginx.org/download/nginx-0.8.54.tar.gz
tar xzvf nginx-0.8.54.tar.gz
cd nginx-0.8.54/
./configure \
–prefix=/home/gamexg/web \
–sbin-path=/home/gamexg/web/sbin/nginx \
–conf-path=/home/gamexg/web/etc/nginx/nginx.conf \
–error-log-path=/home/gamexg/web/var/log/nginx/error.log \
–pid-path=/home/gamexg/web/var/run/nginx/nginx.pid \
–lock-path=/home/gamexg/web/var/lock/nginx.lock \
–user=nginx \
–group=nginx \
–with-http_gzip_static_module \
–http-log-path=/home/gamexg/web/var/log/nginx/access.log \
–http-client-body-temp-path=/home/gamexg/web/var/tmp/nginx/client/ \
–http-proxy-temp-path=/home/gamexg/web/var/tmp/nginx/proxy/ \
–http-fastcgi-temp-path=/home/gamexg/web/var/tmp/nginx/fcgi/

make && make install

配置nginx
增加一段记录
location /site1 {
uwsgi_pass 127.0.0.1:9000;
include uwsgi_params;
}

编译安装 uWSGI

sudo aptitude install python-dev libxml2-dev
wget http://projects.unbit.it/downloads/uwsgi-0.9.6.8.tar.gz
tar zxfv uwsgi-0.9.6.8.tar.gz
cd uwsgi-0.9.6.8/
make

配置 django 使用 uWSGI
gamexg@vps1:~/web$ mkdir site
gamexg@vps1:~/web$ cd site
gamexg@vps1:~/web/site$ mkdir site1
gamexg@vps1:~/web/site$ cd site1/
gamexg@vps1:~/web/site/site1$ mkdir www
gamexg@vps1:~/web/site/site1$ mkdir www/static
gamexg@vps1:~/web/site/site1$ django-admin startproject site1
gamexg@vps1:~/web/site/site1$ cd site1/
gamexg@vps1:~/web/site/site1/site1$ ./manage.py startapp app1
gamexg@vps1:~/web/site/site1/site1$ vi myapp.py
gamexg@vps1:~/web/site/site1/site1$ cat myapp.py
import os
os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘test1.settings’
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

vi uwsgi.xml

127.0.0.1:9000
true /home/gamexg/web/var/uwsgi.pid 3 /home/gamexg/web/site/site1/site1 /home/gamexg/web/site/site1 myapp

启动
/home/gamexg/web/uwsgi-0.9.6.8/uwsgi -x /home/gamexg/web/site/site1/uwsgi.xml

发表评论

电子邮件地址不会被公开。