我在使用 nginx 设置 uWSGI+piwik 时遇到问题。我的配置如下博客条目。我的 uwsgi ini 文件如下所示
[uwsgi]
plugins = php
chown-socket = www-data:www-data
uid = piwik
gid = piwik
processes = 1
和我的 nginx 配置
server {
listen 80;
root /var/www/piwik;
server_name my.domain.com;
index piwik.php;
# For administrative access
location = /index.php {
include uwsgi_params;
uwsgi_modifier1 14;
uwsgi_pass unix:/var/run/uwsgi/app/piwik/socket;
allow 127.0.0.1; # only via ssh tunnel
deny all;
}
# For public access
location = /piwik.php {
include uwsgi_params;
uwsgi_modifier1 14;
uwsgi_pass unix:/var/run/uwsgi/app/piwik/socket;
}
# Any other attempt to access PHP files is forbidden
location ~* ^.+\.php$ {
return 403;
}
# Redirect to the root if attempting to access a txt file.
location ~* (?:DESIGN|(?:gpl|README|LICENSE)[^.]*|LEGALNOTICE)(?:\.txt)*$ {
return 302 /;
}
# Disallow access to several helper files.
location ~* \.(?:bat|html?|git|ini|sh|svn[^.]*|txt|tpl|xml)$ {
return 404;
}
# Disallow access to directories
location ~ ^/(config|core|lang|misc|tmp)/ {
deny all;
}
}
日志文件包含以下内容,表明存在错误:
Tue Aug 25 15:34:34 2015 - PHP Fatal error: Uncaught exception 'Exception' with message 'The configuration file {/var/www/piwik/config/config.ini.php} has not been found or could not be read.' in /var/www/piwik/core/Application/Kernel/EnvironmentValidator.php:64
Stack trace:
#0 /var/www/piwik/core/Application/Kernel/EnvironmentValidator.php(45): Piwik\Application\Kernel\EnvironmentValidator->checkConfigFileExists('/var/www/piwik/...', false)
#1 /var/www/piwik/core/Application/Environment.php(185): Piwik\Application\Kernel\EnvironmentValidator->validate()
#2 /var/www/piwik/core/Application/Environment.php(94): Piwik\Application\Environment->validateEnvironment()
#3 /var/www/piwik/piwik.php(56): Piwik\Application\Environment->init()
#4 {main}
thrown in /var/www/piwik/core/Application/Kernel/EnvironmentValidator.php on line 64
[pid: 23656|app: -1|req: -1/3] 109.90.112.120 () {36 vars in 567 bytes} [Tue Aug 25 15:34:34 2015] GET / => generated 0 bytes in 58 msecs (HTTP/1.1 500) 1 headers in 78 bytes (0 switches on core 0)
当我用浏览器打开页面时,会生成类似这样的日志条目,并且我看到一个空白页(生成 0 个字节是有意义的)。问题是预期的 Piwik 安装脚本没有启动。而是引发了异常。我尝试更改/var/www/piwik/core/Application/Kernel/EnvironmentValidator.php
为手动触发设置,但没有成功。你有什么想法吗?
答案1
您正在请求 /piwik.php(如果您请求 /,则 /piwik.php 被标记为默认)。/piwik.php 是跟踪器。您必须先请求 /index.php,然后使用 Web 管理界面生成配置文件。