由于项目需要微服务,本地也就产生了服务访问服务之间的需求。
本地跨域访问
以下配置文件解决问题:
错误二:file not found
大概了为nginx配置文件错误
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
解决办法:注释掉原来的fastcgi_param
问题三:thinkphp访问路径如何忽略index.php(伪静态) :
#nginx配置文件里
location / {
index index.html index.htm index.php;
#autoindex on;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1;
}
}
问题四:PHP 项目 该网页无法正常运作情况,但没有报错code 500
修改php.ini可以看到错误信息 display_errors = On display_startup_errors = On
问题五file_put_contents (/PHP/admin/tp/runtime/temp/71dafaa2a0ea0d586666de9d67f301a7.php) failed to open stream: Permission denied
解决方法:chmod -R 777 runtime
问题六:将PHP项目部署到新服务器上的PHP环境时,发生报错:scandir() symlink() has been disabled for security reasons。
解决:只需要去PHP安装目录找到php.ini,ctrl+F搜索“disable_functions”,找到scandir() 删除掉就可以了
问题七:TP5报错Fatal error: require(): Failed opening required '/home/www/xx/public/../thinkphp/start.php
解决: #fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; (注释这行就可以了)
问题八:nginx报错502
错误截图:
502报错的情况一般都为nginx没办法解析php文件,大概率是php那边的问题,首先排查php是否能正常启动,查看9000端口
使用命令:netstat -lntp
很显然9000端口未正常启动,正常的如下:
查看 php-fpm.conf文件:
查看后发现文件两处错误:
1.首先#不能为php-fpm注释应该使用;
2.listen. allowed clients =127.0.0.1 #可以向这个 PHP-FPM进程池发送请求的IP地址(一个或多个)。