我知道有重复的问题,但没有一个答案似乎有帮助。
我有两个虚拟主机:dvc-raspberrypi.local.com
和dvc-flask-app.com
。后者通过mod_wsgi
托管我的Flask应用程序。我还为后者设置了代理映射(mod_proxy
和mod_http_proxy
)dvc-raspberrypi.local.com/device
。
例如,如果我调用dvc-raspberrypi.local.com/device/logs?from=2016-09-16T00:00:00&to=2016-09-16T23:59:59
,我希望从Flask主机返回一个JSON。
我的apache2错误日志说:
con = sqlite3.connect('/var/www/dvc-flask-app.com/logs.db', detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
sqlite3.OperationalError: unable to open database file
我的权限如下:
drwxrwxr-x 4 www-data www-data 4096 Sep 16 21:20 dvc-flask-app.com
内心:
-rwxrwxrwx 1 www-data www-data 411648 Sep 16 21:10 logs.db
我清楚地获得了apache2用户的所有权和权限。为什么还给我这个错误?
# dvc-flask-app.com.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName dvc-flask-app.com
ServerAlias www.dvc-flask-app.com
WSGIDaemonProcess dvc-flask-app user=www-data group=www-data threads=5
WSGIScriptAlias / /var/www/dvc-flask-app.com/dvc-embedded.wsgi
ServerAdmin webmaster@localhost
DocumentRoot /var/www/dvc-flask-app.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory /var/www/dvc-flask-app.com>
WSGIScriptReloading On
WSGIProcessGroup dvc-flask-app
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
我不知道我做了什么,但它现在有效。这是我更新的VHost配置:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName dvc-flask-app.com
ServerAlias www.dvc-flask-app.com
WSGIDaemonProcess dvc-flask-app user=www-data group=www-data threads=5
WSGIScriptAlias / /var/www/dvc-flask-app.com/dvc-embedded.wsgi
ServerAdmin webmaster@localhost
DocumentRoot /var/www/dvc-flask-app.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory /var/www/dvc-flask-app.com>
WSGIScriptReloading On
WSGIProcessGroup dvc-flask-app
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet