我试图让 zabbix-frontend 与 nginx 一起工作。这是我的 nginx 配置文件:
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/
中。
为什么会这样,我该如何解决?