server {
listen 80;
server_name www.local.test;
root /data/workspace;
index index.php index.html index.htm;
error_page 404 502 503 =200 /index.html;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/run/php/php7.2-fpm.sock;
try_files $uri =404;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
- fastcgi_pass #用来指定php-fpm监听的地址或者socket
- fastcgi_index index.php #设定访问根目录默认去找的文件
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name #设置访问根目录时默认寻找的文件
修改完成后
测试nginx配置是否正确: /usr/local/nginx/sbin/nginx -t
平滑重启nginx服务: /usr/local/nginx/sbin/nginx -s reload