首页 > 代码库 > python django uwsgi nginx 实例
python django uwsgi nginx 实例
实例:192.168.200.133
1.安装django
wget https://www.djangoproject.com/download/1.7.11/tarball/
1.3.安装
cd Django-1.x.y sudo python setup.py install
1.4.创建
django-admin.py startproject testdj
1.5.启动测试
cd testdj # 切换到我们创建的项目
python manage.py runserver
2.安装 uwsgi
wget https://projects.unbit.it/downloads/uwsgi-2.0.14.tar.gz
tar xvf uwsgi-2.0.14.tar.gz
cd uwsgi
make
报错: plugins/python/uwsgi_python.h:2:20: error: Python.h: No such file or directory
yum install python-devel ###再make 编译通过
3.配置nginx
server{
listen 80;
server_name localhost;
location / {
uwsgi_pass 127.0.0.1:9090;
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/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/OMserverweb/static;
access_log off;
}
}
cd /data/www/
ls
django-admin.py startproject OMserverweb
4配置nginx uwsgi.ini
cat /usr/local/nginx/conf/uwsgi.ini
[uwsgi]
socket = 0.0.0.0:9090
master = true
pidfile = /var/run/uwsgi.pid
processes = 8
chdir = /data/www/OMserverweb
pythonpath = /data/www/
profiler = true
memory-report=true
enable-threads=true
logdate=true
limit-as=6048
daemonize=/data/nginx/logs/django.log
5.启动
# uwsgi --ini /usr/local/nginx/conf/uwsgi.ini # /usr/local/nginx/sbin/nginx -t /usr/local/nginx/sbin/nginx 至此,配置结束,测试成功;谢谢; |
本文出自 “好先生2020” 博客,请务必保留此出处http://fuyuan2016.blog.51cto.com/8678344/1883785
python django uwsgi nginx 实例