小编J D*_*J D的帖子

Django 2.1 在 centos 7 上部署,使用 apache、mod_wsgi、python3 venv

我偶然发现了这个看似最相关的部署选项,因为指南似乎要么使用 python2 引用 mod_wsgi,要么在预期路径不同的基于 deb 的系统上进行部署。
所以我按照以下步骤操作:

#repos for python3.6, wsgi for python3.6
yum install epel-release centos-release-scl

#base packages
yum install python36 python36-devel httpd httpd-devel rh-python36-mod_wsgi

#python3.6 venv
cd /var/www; 
python36 -m venv django-venv
source django-venv/bin/activate
pip3 install django

#apache config to support wsgi
edit /etc/httpd/conf/httpd.conf to include
LoadModule wsgi_module modules/mod_wsgi.so
Run Code Online (Sandbox Code Playgroud)

Apache 配置服务位于 /var/www/mysite 的 django 内容

<VirtualHost *:80>
 ServerAdmin foo@mysite.com
 ServerName mysite.com
 ServerAlias www.mysite.com

 WSGIDaemonProcess mysite python-home=/var/www/django-venv/ python-path=/var/www/django-venv/lib/python3.6/site-packages
 WSGIProcessGroup mysite
 WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py

 Alias /static /var/www/mysite/static
 <Directory /var/www/mysite/mysite/static>
  Require …
Run Code Online (Sandbox Code Playgroud)

python django mod-wsgi centos7

1
推荐指数
1
解决办法
7275
查看次数

标签 统计

centos7 ×1

django ×1

mod-wsgi ×1

python ×1