@zoand
2018-08-03T14:36:54.000000Z
字数 1175
阅读 1500
php lnmp thinkphp5
CentOS7.2-amd64 + lnmp 1.5 + thinkphp5.1 lnmp 事先已经添加 vhost 目录于 /home/wwwroot/www.xxx.com 中;vhost 时已经选择 rewrite/thinkphp.conf 重写规则配置及 enable-php-pathinfo.conf 配置;public下1). 先修改域名对应的配置 /conf/vhost/www.xxx.com.conf :
server{listen 443 ssl http2;#listen [::]:443 ssl http2;server_name www.xxx.com ;index index.html index.htm index.php;root /home/wwwroot/www.xxx.com/public;......}server{listen 80;#listen [::]:80;server_name api.nasm.io ;index index.html index.htm index.php default.html default.htm default.php;root /home/wwwroot/www.xxx.com/public;return 301 https://$server_name$request_uri;}
2). 修改 /usr/local/nginx/conf/fastcgi.conf 中的:
fastcgi_param REDIRECT_STATUS 200;fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/../:/tmp/:/proc/";
3.1). 删除 /home/wwwroot/www.xxx.com/.user.ini ,要先解除权限锁定
//原内容为:open_basedir=/home/wwwroot/www.xxx.com/:/tmp/:/proc/> chattr -i .user.ini
3.2). 新建 /home/wwwroot/www.xxx.com/public/.user.ini,再添加权限锁定
open_basedir=/home/wwwroot/www.xxx.com/public/:/tmp/:/proc/> chattr +i .user.ini
4). 修改 php.ini
`cgi.fix_pathinfo = 0` 改为 `cgi.fix_pathinfo = 1;`
5). 重启环境:
> lnmp nginx reload> lnmp restart
public/index.php 入口文件如果按上述修改,已经自动支持隐藏 index.php 入口文件了。