有时候不知道自己的nginx配置的规则到底有没有问题,可以在规则下简单使用return语句进行测试
例子如下:
server {
listen 80;
server_name localhost;
error_log /tmp/logs/localhost/error.log;
access_log /tmp/logs/localhost/access.log;
root /data/www/localhost/public;
index index.php;
location ~ \.(gif|jpg|png|js|css|html|ico)$ {
default_type text/html;
return 200 "static";
#root /data/www/localhost/dist/;
}
location / {
default_type text/html;
return 200 "222";
#try_files $uri $uri/ /index.php?s=$uri&$query_string;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
如上配置设置之后,我想测试php入口和静态资源入口规则有没有生效。