安裝nginx
wget http://nginx.org/download/nginx-1.6.3.tar.gz
./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-cc-opt='-03' --with-cpu-opt=opteron
報pcre錯誤:
yum -y install pcre-devel
yum -y install zlib-devel
yum -y install MySQL-python
安裝uwsgi
wget http://projects.unbit.it/downloads/uwsgi-2.0.12.tar.gz
tar -zxvf uwsgi-2.0.12.tar.gz
cd uwsgi
python setup.py build
python setup.py install
出現報錯:plugins/python/python_plugin.c:1862: error:
安裝python-devel
##################################
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return "Hello World"
################################## test.py
uwsgi --http :8001 --wsgi-file test.py
在data/www/下建立omswanbu項目
django-admin.py startproject omswanbu
配置uwsgi:
在/usr/local/nginx/conf/下建立uwsgi.ini配置文件,內容以下:
[uwsgi]
socket = 0.0.0.0:9000
master = true
pidfile = /usr/local/nginx/uwsgi.pid
processes = 8
chdir = /data/www/omswanbu
env = DJANGO_SETTINGS_MODULE=omswanbu.settings
module = django.core.handlers.wsgi:WSGIHandler()
pythonpath = /data/www
profiler = true
memory-report = true
enable-threads = true
logdate = true
limit-as = 6048
daemonize = /data/logs/django.log
配置nginx:
server {
listen 80;
server_name 192.168.20.183;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
uwsgi_pass 192.168.20.183:9000;
include uwsgi_params;
uwsgi_param UWSGI_CHDIR /data/www/omswanbu;
uwsgi_param UWSGI_SCRIPT omswanbu.wsgi; #建立項目下的wsgi.py文件,"omswanbu."表明的是路徑
access_log off;
}
location ^~ /static {
root /data/www/omswanbu;
}
location ~* ^.+\.(mpg|avi|mp3|swf|zip|tgz|gz|rar|bg2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg)$ {
root /data/www/omswanbu/static;
access_log off;
}
啓動uwsgi:
/
usr/bin/uwsgi --ini /data/www/omswanbu/prod.ini
啓動nginx:/usr/local/nginx/sbin/nginx
訪問頁面:http://192.168.20.183/