我试图让zabbix-frontend与nginx一起工作。 这是我的nginx conf:
server {
listen 80;
server_name localhost;
root /var/www/test/htdocs;
index index.php index.html index.htm;
location /zabbix {
alias /usr/share/zabbix;
index index.php;
error_page 403 404 502 503 504 /zabbix/index.php;
location ~ \.php$ {
if (!-f $request_filename) { return 404; }
expires epoch;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location ~ \.(jpg|jpeg|gif|png|ico)$ {
access_log off;
expires 33d;
}
}
location / {
try_files $uri $uri/ /index.php;
include /etc/nginx/proxy_params;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_read_timeout 120;
include /etc/nginx/fastcgi_params;
}
include /etc/nginx/security;
include /etc/nginx/main_rules;
}
/ zabbix中的 php脚本正在运行!但是没有提供像/usr/share/zabbix/css.css
这样的文件(404)。在错误日志中是这样的:
2013/07/19 20:23:33 [error] 13583#0: *1 open() "/var/www/test/htdocs/zabbix/css.css" failed (2: No such file or directory), client: xxx, server: localhost, request: "GET /zabbix/css.css HTTP/1.1"
我们可以看到,nginx正在主根目录/var/www/test/htdocs/
中而不是在别名目录/usr/share/zabbix/
中查找该文件。
为什么会这样,我该如何解决?
答案 0 :(得分:2)
我会尝试将它们分开。 / zabbix只有别名和〜^ / zabbix / * .php $ with fastcgi。两者都位于/根位置之外。