在ubuntu 12.04上在Apache 2.2上部署Django 2.0

时间:2018-01-17 10:04:51

标签: python django apache ubuntu

我的环境:

ubuntu 12.04 / python3.6.4 / django 2.0 / apache 2.2.22

我想在apache上部署newsite

我关注django official

我想部署在

www.domainname.com/newsite /

我的httpd.conf

<Directory /home/usr/project_name/project_name>
    <Files wsgi.py>
      Order deny,allow
      Deny from all
    </Files>
</Directory>
WSGIDaemonProcess site python-path=/home/usr/site
WSGIProcessGroup site
WSGIScriptAlias /newsite/  /home/usr/project_mame/project_name/wsgi.py

如果我在python-home中添加我的虚拟环境,我无法通过configtest

我浏览127.0.0.1它显示了apache'它工作'页面

但127.0.0.1/newsite我刚刚获得403禁止

日志:服务器配置拒绝客户端:xxxxxx / xxxxxx / wsgi.py

1 个答案:

答案 0 :(得分:0)

尝试:

<VirtualHost *:9002>

        ServerName complete_hostname #result of hostname -f

        WSGIDaemonProcess Django_project_name python-path=/var/www/html/Django_project_name
        WSGIProcessGroup Django_project_name 
        WSGIScriptAlias / /var/www/html/Django_project_name/Django_project_name /wsgi.py

        <Directory /var/www/html/Django_project_name/Django_project_name >
        <Files wsgi.py>
                Require all granted               
        </Files>
        </Directory>    
</VirtualHost>

如果您使用的是早于2.4版本的Apache,请将Require all granted替换为Allow from all,并在其上方添加行Order deny,allow