lnmp完美搭建核心thinkphp5的易優CMS站點配置

小虎哥-技術部落格發表於2018-08-10

1、概述

易優CMS核心採用thinkphp5,有些nginx伺服器不能訪問,是因為要開啟pathinfo。

 

2、配置

修改 php.ini 支援 pathinfo

php配置檔案:/usr/local/php/etc/php.ini

更改php.ini

  1. 找到:cgi.fix_pathinfo=0  更改為:cgi.fix_pathinfo=1
  2. 找到:scandir,去掉禁止函式中的 scandir

3、配置nginx新站點

server
    {
        listen 80;
        server_name www.xxxxxxx.com xxxxxxx.com;
        index index.php index.html index.htm default.html default.htm default.php;
        root  /home/wwwroot/www.xxxxxxx.com/;

        include none.conf;
        #error_page   404   /404.html;
        #include enable-php.conf;
        include enable-php-pathinfo.conf;

        location / {
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.php?s=/$1 last;
                break;
            }
        }

        if ($host != 'www.xxxxxxx.com' ) {
            rewrite ^/(.*)$ http://www.xxxxxxx.com/$1
            permanent;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        #access_log  /home/wwwlogs/www.xxxxxxx.com.log;
    }

 

enable-php-pathinfo.conf 檔案程式碼:

location ~ [^/]\.php(/|$)
{
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    set $path_info $fastcgi_path_info;
    fastcgi_param PATH_INFO       $path_info;
    #try_files $fastcgi_script_name =404;
    include fastcgi.conf;
}

 

4、重啟

lnmp restart

 

注意:

一定要帶上 include enable-php-pathinfo.conf;

否則會報404錯誤

 

 

相關文章