uwsgi - 如何用nginx关联django应用
问题描述
Django:1.6.5,python:2.6,centOS: 6.5 ,nginx:1.8.0-1
django应用下有wsgi.py和prod.ini文件
prod.ini文件:
wsgi.py:
可是怎么将其与nginx关联起来,我是通过yum install nginx安装的nginx,修改了/etc/nginx/conf.d/myapp.conf 文件,内容如下:
请问该怎么配置呢?
问题解答
回答1:将/etc/nginx/conf.d/myapp.conf中的9090将为8000,然后将server 8000改为别的端口,如80端口。
然后为了显示图片、js、css,需要下面的配置
location /static/ { alias /home/www/MK_dream/MK_dream/static; if ($query_string) {expires max; } expires 30d;}location /static/media/ { alias /home/www/MK_dream/MK_dream/static/media; if ($query_string) {expires max; } expires 30d;}location ~* ^.+.(cur|ico|json|gif|jpeg|cur|jpg|png|ttf|otf|js|css|mpg|avi|mp3|swf|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|txt|tar|mid|midi|wav|rtf|mpeg|woff)$ { root /home/www/MK_dream/MK_dream/; expires 30d; access_log off;}
如果配置成功,建议可以使用gunicorn替换uwsgi,性能更好。
相关文章:
1. docker gitlab 如何git clone?2. 网页爬虫 - Python:爬虫的中文编码问题?3. javascript - 修改表单多选项时和后台同事配合的问题。4. ubuntu 远程管理KVM设置问题5. javascript - vue生成一维码?求助!!!!!急6. css - 手机页面在安卓和苹果浏览器显示不同的小小问题7. javascript - 关于Js中 this的一道题8. angular.js - angularjs如何动态改变ng-model值,在controller中获取input中输入的值并组合post发送到后台9. javascript - H5页面怎么查看console信息?10. browsersync检测的静态页面只能用index.html命名,用demo.html就不能实时同步,检测动态页面的时候,比如wamp环境下,用browsersync能打开页面,但不能实现同步
