Fork me on GitHub

TP5 在 lnmp 环境下必要的配置

tp5 默认在 nginx 服务器 是不能正常工作的,需要我们手动配置 nginx 服务器 以便对 tp 5 的支持!

打开 Nginx 站点配置文件

$ sudo vi /etc/nginx/vhost/vhost_siteA.conf

编辑站点配置文件

#自定义服务器配置开始

server {
        listen       80;                        # 监听端口
        server_name www.test.com test.com;    # 站点域名
        set        $root    /var/www/html/shengteng-group/public/;              # 站点根目录
        location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
    {
        root $root;
    }
    location / {
        root    $root;
        index    index.html index.php;
        if ( -f $request_filename) {
            break;
        }
        if ( !-e $request_filename) {
            rewrite ^(.*)$ /index.php/$1 last;
            break;
        }
    }
    location ~ .+\.php($|/) {
        fastcgi_pass    unix:/run/php/php7.0-fpm.sock;
        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;
    }
}
#自定义服务器配置结束

重启 Nginx 服务器 即可

$ service nginx restart
posted @ 2019-12-06 16:57  君乐豹  阅读(361)  评论(0编辑  收藏  举报
Live2D