我在使用wsgi在apache2上部署烧瓶应用程序时遇到问题。 Apache2重启就好像运行正常,但当我尝试使用浏览器访问它时,我收到“403 Forbidden”错误。这是我的代码。
webroombooker.wsgi
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/home/pi/Website/webroombooker.py")
from webroombooker import app as application
这是Flask应用程序和wsgi文件目录的目录树。
/home/pi/Website
├── hellotest.py
├── hellotest.pyc
├── index.html.en
├── index.html.en~orig.html
├── main.html
├── PoweredByMacOSX.gif
├── PoweredByMacOSXLarge.gif
├── templates
│ ├── profile.html
│ ├── registration2.html
│ ├── registration.html
│ ├── seleniumtemplate2.html
│ └── seleniumtemplatetime.html
├── Test
├── webroombooker.py
├── webroombooker.pyc
└── webroombooker.wsgi
这是apache虚拟主机文件。
<VirtualHost *:80>
ServerName localhost
WSGIScriptAlias / /home/pi/Website/webroombooker.wsgi
<Directory /home/pi/Website/webroombooker.py/>
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
以下是相关的错误日志行 实际上它现在显示错误。
[Thu Nov 17 14:07:39.939432 2016] [authz_core:error] [pid 15949:tid 1972368432] [client ::1:55490] AH01630: client denied by server configuration: /home/pi/Website/webroombooker.wsgi
[Thu Nov 17 14:07:40.260731 2016] [authz_core:error] [pid 15949:tid 1963979824] [client ::1:55490] AH01630: client denied by server configuration: /home/pi/Website/webroombooker.wsgi, referer: http://localhost/
[Thu Nov 17 14:07:43.506135 2016] [authz_core:error] [pid 15949:tid 1955591216] [client ::1:55490] AH01630: client denied by server configuration: /home/pi/Website/webroombooker.wsgi
[Thu Nov 17 14:07:43.702542 2016] [authz_core:error] [pid 15949:tid 1947202608] [client ::1:55490] AH01630: client denied by server configuration: /home/pi/Website/webroombooker.wsgi, referer: http://localhost/
我对此很新,所以我真的很感激。谢谢你的帮助。
答案 0 :(得分:0)
这可能是您对apache正在访问的某个文件的unix权限的结果。 Apache以用户www-data
运行,因为文件可能由您的用户拥有。尝试为相关文件运行sudo chmod a+w <filename>
,这可能是您的wsgi文件