django专题—整合apache整合nginx
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了django专题—整合apache整合nginx相关的知识,希望对你有一定的参考价值。
八、Djiango结合apache—wsgi模块
1)安装模块
yum install -y mod_wsgi
yum install -y httpd
说明:apache 自动加载配置文件模块
cat /etc/httpd/conf.modules.d/10-wsgi.conf
LoadModule wsgi_module modules/mod_wsgi.so
2)创建一个新的配置文件
cat /etc/httpd/conf.d/django.conf
<VirtualHost *:80> WSGIDaemonProcess simplecmdb python-path=/opt/simplecmdb:/usr/lib64/python2.7/site-packages WSGIProcessGroup simplecmdb WSGIScriptAlias / /opt/simplecmdb/simplecmdb/wsgi.py Alias /static /usr/lib64/python2.7/site-packages/django/contrib/admin/static </VirtualHost> <Directory "/opt/simplecmdb/simplecmdb"> Require all granted </Directory> <Directory "/usr/lib64/python2.7/site-packages/django/contrib/admin/static"> Require all granted </Directory> WSGISocketPrefix /var/run/wsgi
说明:/opt 为项目路径,可以先拷贝出来,不能是root目录下;以及jdango包所在的路径
cp -rp simplecmdb/ /opt/
chown -R apache:apache /opt/simplecmdb
3)启动apache
4)访问
九、django结合nginx—gunicron模块
1)安装模块,需要epel扩展源
yum install -y nginx
pip install gunicron
2)修改nginx的配置文件
cat /etc/nginx/conf.d/virtual.conf server { listen 192.168.2.230:9000; server_name localhost; location /static/admin { root /usr/lib64/python2.7/site-packages/django/contrib/admin/; index index.html index.htm; } location / { proxy_pass http://localhost:8000; } }
3)启动配置文件和nginx
gunicorn simplecmdb.wsgi:application -D
systemctl start nginx.service
4)启动nginx,查看
以上是关于django专题—整合apache整合nginx的主要内容,如果未能解决你的问题,请参考以下文章
django + vue整合后,部署到windows apache遇到的问题汇总