【问题标题】:Apache mod_wsgi error: file not found (when the file exists)Apache mod_wsgi 错误:找不到文件(当文件存在时)
【发布时间】:2015-02-22 05:40:53
【问题描述】:

所以我只是想在我的 Apache 服务器上显示一个简单的页面。

我有一个 wsgi 文件:/var/www/html/wsgi/myapp.wsgi

我的 /etc/apache2/sites-available/000-default.conf 文件如下所示:

<VirtualHost *:80>


    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/html>
    Order allow,deny
    Allow from all
    </Directory>  

    WSGIScriptAlias /wsgi/myapp /var/www/html/wsgi/myapp.wsgi

    <Directory /var/www/html/wsgi>
    Order allow,deny
    Allow from all
    </Directory>    

</VirtualHost>

这是error.log(日志级别为info):

[Sun Feb 22 00:08:40.001384 2015] [mpm_prefork:notice] [pid 22390] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.6 mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Sun Feb 22 00:08:40.001441 2015] [mpm_prefork:info] [pid 22390] AH00164: Server built: Jul 22 2014 14:36:38
[Sun Feb 22 00:08:40.001464 2015] [core:notice] [pid 22390] AH00094: Command line: '/usr/sbin/apache2'
[Sun Feb 22 00:08:40.001976 2015] [:info] [pid 22505] mod_wsgi (pid=22505): Initializing Python.
[Sun Feb 22 00:08:40.003966 2015] [:info] [pid 22504] mod_wsgi (pid=22504): Initializing Python.
[Sun Feb 22 00:08:40.008001 2015] [:info] [pid 22502] mod_wsgi (pid=22502): Initializing Python.
[Sun Feb 22 00:08:40.011764 2015] [:info] [pid 22503] mod_wsgi (pid=22503): Initializing Python.
[Sun Feb 22 00:08:40.018442 2015] [:info] [pid 22501] mod_wsgi (pid=22501): Attach interpreter ''.
[Sun Feb 22 00:08:40.029632 2015] [:info] [pid 22502] mod_wsgi (pid=22502): Attach interpreter ''.
[Sun Feb 22 00:08:40.035609 2015] [:info] [pid 22505] mod_wsgi (pid=22505): Attach interpreter ''.
[Sun Feb 22 00:08:40.038286 2015] [:info] [pid 22504] mod_wsgi (pid=22504): Attach interpreter ''.
[Sun Feb 22 00:08:40.041199 2015] [:info] [pid 22503] mod_wsgi (pid=22503): Attach interpreter ''.
[Sun Feb 22 00:08:49.444674 2015] [core:info] [pid 22501] [client 10.0.0.58:57209] AH00128: File does not exist: /var/www/wsgi/myapp

我从this site 收集到,这实际上不是文件存在的问题,而是 wsgi 模块的问题,但我似乎无法弄清楚问题所在。

【问题讨论】:

    标签: apache mod-wsgi wsgi


    【解决方案1】:

    试试

    <VirtualHost *:80>
    
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    
        WSGIScriptAlias /wsgi/myapp /var/www/html/wsgi/myapp.wsgi
    
        <Directory /var/www/html/wsgi/myapp>
        Order allow,deny
        Allow from all
        </Directory>    
    
    </VirtualHost>
    

    【讨论】:

      【解决方案2】:

      您尝试使用错误的 URL 访问此应用 - 正确的是:

      http://localhost/wsgi/myapp/wsgi
      

      对于远程主机,将localhost 替换为域名或IP 地址。

      或者您没有将/etc/apache2/sites-available/000-default.conf/etc/apache2/sites-enabled/000-default.conf 符号链接。创建此符号链接后不要忘记重新加载/重新启动 apache。

      顺便说一句。您的配置中带有ErrorLogCustomLog 的行不是必需的,因为它们指向默认日志位置。

      【讨论】:

        【解决方案3】:

        试试这个:

        <VirtualHost *:80>
            ...
            <Directory "/var/www/html/wsgi/">
                <Files myapp.wsgi>
                    Allow from all
                    Order deny,allow
                </Files>
             </Directory>  
        

        重启apache ...

        【讨论】:

          猜你喜欢
          • 2023-03-02
          • 1970-01-01
          • 1970-01-01
          • 2012-07-19
          • 1970-01-01
          • 2013-07-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多