1、概述
易优CMS内核采用thinkphp5,有些nginx服务器不能访问,是因为要开启pathinfo。
2、配置
修改 php.ini 支持 pathinfo
php配置文件:/usr/local/php/etc/php.ini
更改php.ini
- 找到:cgi.fix_pathinfo=0 更改为:cgi.fix_pathinfo=1
- 找到: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错误