当前位置: 移动技术网 > IT编程>开发语言>PHP > ThinkPHP5 Nginx通用配置

ThinkPHP5 Nginx通用配置

2019年07月10日  | 移动技术网IT编程  | 我要评论

项目配置内容如下:

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.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;
    }
}

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网