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
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
Require all granted
Require all granted
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,查看
页:
[1]