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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章