server {
#配置监听端口
listen 80;
listen [::]:80;
#设置网站根目录作为变量root
set $root /var/www/web;
#设置网站根目录
root $root;
#设置访问日志存放路径
#access_log logs/access.log;
#设置错误日志存放路径
#error_log logs/error.log;
#设置网站默认首页
index index.html index.php;
#设置域名
server_name www.example123.com;
#设置字符集
charset utf-8;
#此配置用于静态文件配置
#location /static {
#try_files $uri $uri/ =404;
#}
#配置PHP的重写规则
location / {
#开启目录浏览功能
#autoindex on;
#关闭详细文件大小统计,让文件大小显示MB,GB单位,默认为b
#autoindex_exact_size on;
#开启以服务器本地时区显示文件修改日期
#autoindex_localtime on;
if ( !-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
#配置PHP的pathinfo
location ~ .+\.php($|/) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
include fastcgi_params;
}
}