您现在的位置是:网站首页> 编程资料编程资料

解决tp5在nginx下修改配置访问的问题_php实例_

2023-05-25 507人已围观

简介 解决tp5在nginx下修改配置访问的问题_php实例_

第一:修改nginx配置

注意:所有配置都是基于lnmp1.4的一键安装环境的

根据自己的nginx配置,找到正确的fastcgi.conf,修改fastcgi_param参数

将默认的路径修改至自己的项目根目录的上一级,注意是上级!!!

3、lnmp nginx reload

lnmp nginx restart

第二:执行service nginx restart命令重启nginx,发现网页报404错误,需要配置一下伪静态可以在/usr/local/nginx/conf/www.tp5.com.conf(根据实际情况而定)添加:

 location ~ .*\.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } 

代码放在server{} 内

第三:

php错误scandir() has been disabled for security reasons

原因:

php.ini里禁用了scandir()方法

解决:

编辑php.ini文件

 disable_functions = scandir,passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,fsockopen 

去掉scandir保存并重起php-fpm即可。

php.ini 的位置:/usr/local/php/etc/php.ini

最后执行/etc/init.d/php-fpm restart重启下

以上这篇解决tp5在nginx下修改配置访问的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

-六神源码网