简体   繁体   English

使用mod_wsgi用apache设置Django

[英]Setup Django with apache using mod_wsgi

I am trying to setup my django application with apache2 which has been created using virtualenv. 我正在尝试使用已使用virtualenv创建的apache2设置django应用程序。 Please find my virualhost configuration 请找到我的virualhost配置

`WSGIPythonPath  /path/to/environment/folder/.env/lib/python2.7/site-packages
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
        ServerName myapp.example.com 
    DocumentRoot /path/to/mydjangoapp/folder

    AddHandler cgi-script .cgi .pl .py
    <Directory /path/to/mydjangoapp/folder>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
        <Files wsgi.py>
            Require all granted
        </Files>
#       Order allow,deny
#                allow from all
    </Directory>

    WSGIScriptAlias / /path/to/mydjangoapp/folder/wsgi.py
#   <Directory /var/www/>
#       Options Indexes FollowSymLinks MultiViews
#       AllowOverride All
#       Order allow,deny
#       allow from all
#   </Directory>


    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
`

And my wsgi file contain default values which django gives when you create project. 我的wsgi文件包含django在创建项目时提供的默认值。 I have installed the mod_wsgi. 我已经安装了mod_wsgi。 When i am trying to access the domain , as i have used debug level of warning i am getting message as AH00130: File does not exist: /path/to/mydjangoapp/folder/wsgi.py/ with 404 error code 当我尝试访问域时,因为我使用过警告的调试级别,所以我收到的消息为AH00130:文件不存在:/path/to/mydjangoapp/folder/wsgi.py/,错误代码为404

Please let me know is there anything wrong in my virtual host settings or any other issue. 请让我知道我的虚拟主机设置有任何问题或其他问题。

Thanks 谢谢

This issue is fixed when i renamed the file wsgi.py to my.wsgi. 当我将文件wsgi.py重命名为my.wsgi时,此问题已修复。 I am not sure that why this worked for me. 我不确定为什么这对我有用。 as i read on django forums that we need to give the wsgi.py file path but it was not working for me. 当我在django论坛上阅读时,我们需要提供wsgi.py文件路径,但它对我不起作用。 Just wanted to update all that in case if someone is facing the same issue he can try out this thing too :) 只是想更新所有这些,以防万一有人遇到相同的问题,他也可以尝试一下:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM