![NGinX 和 VHost 配置遇到无法找到命名位置“@handler”错误](https://linux22.com/image/672043/NGinX%20%E5%92%8C%20VHost%20%E9%85%8D%E7%BD%AE%E9%81%87%E5%88%B0%E6%97%A0%E6%B3%95%E6%89%BE%E5%88%B0%E5%91%BD%E5%90%8D%E4%BD%8D%E7%BD%AE%E2%80%9C%40handler%E2%80%9D%E9%94%99%E8%AF%AF.png)
could not find named location "@handler"
我在我的 VHost 错误日志中多次看到此错误。
server {
listen 80 default;
server_name www.domain.at;
root /var/www/domain.com/www.domain.com;
location / {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
access_log /var/log/nginx/domain.com_access.log;
error_log /var/log/nginx/domain.com_error.log;
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
location /var/export/ {
auth_basic "Restricted";
auth_basic_user_file htpasswd;
autoindex on;
}
location /. {
return 404;
}
location /. {
return 404;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
location /lib/minify/ {
allow all;
}
location ^~ /blog { allow all; }
location ~ .php$ {
if (!-e $request_filename) { rewrite / /index.php last; }
expires off;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;
}
}
uname -a
Linux r3cwzg4q 2.6.32-042stab104.1 #1 SMP Thu Jan 29 12:58:41 MSK 2015 x86_64 GNU/Linux
php -v
PHP 5.6.14-0+deb8u1
ps aux | grep php
www-data 784 0.5 2.0 515804 107228 ? S Nov21 79:16 php-fpm: pool www
www-data 943 0.5 2.4 801532 130400 ? Sl Nov21 79:15 php-fpm: pool www
root 2258 0.0 0.0 471400 4960 ? Ss Okt31 1:36 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
root 8063 0.0 0.0 14136 1048 pts/0 S+ 12:57 0:00 grep php
www-data 14918 1.2 2.6 542560 136828 ? S Nov29 12:13 php-fpm: pool www
www-data 14919 1.2 2.0 514080 105720 ? S Nov29 12:22 php-fpm: pool www
www-data 18119 0.8 2.0 514044 105228 ? S Nov28 19:34 php-fpm: pool www
www-data 21371 0.5 5.5 699180 291196 ? S Nov19 84:26 php-fpm: pool www
www-data 21430 0.8 1.8 506684 98252 ? S Nov29 19:12 php-fpm: pool www
www-data 23462 1.1 1.8 506340 98560 ? S 01:06 8:02 php-fpm: pool www
www-data 23477 1.1 1.6 502256 86356 ? S 01:08 8:14 php-fpm: pool www
www-data 23478 1.1 5.3 692924 282608 ? S 01:08 8:06 php-fpm: pool www
netstat -lpnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:17462 0.0.0.0:* LISTEN 263/sshd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1113/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 6646/nginx: worker
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 1/init
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 275/dovecot
tcp 0 0 127.0.0.1:10024 0.0.0.0:* LISTEN 25740/amavisd-new (
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 861/mysqld
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 1113/master
tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 265/memcached
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 275/dovecot
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 1/init
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6646/nginx: worker
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 1113/master
tcp6 0 0 :::17462 :::* LISTEN 263/sshd
tcp6 0 0 :::25 :::* LISTEN 1113/master
tcp6 0 0 :::993 :::* LISTEN 275/dovecot
tcp6 0 0 :::995 :::* LISTEN 275/dovecot
tcp6 0 0 ::1:10024 :::* LISTEN 25740/amavisd-new (
tcp6 0 0 :::587 :::* LISTEN 1113/master
tcp6 0 0 :::110 :::* LISTEN 275/dovecot
tcp6 0 0 :::143 :::* LISTEN 275/dovecot
tcp6 0 0 :::465 :::* LISTEN 1113/master
这只能来自 try_files $uri $uri/ @handler; ?这有什么问题?