天天看点

将本地TP5项目文件上传到lamp环境上出现500错误

做毕业设计时要android和PHP进行交互,当时没有用ftp同步发到服务器上,后来为了同步就重新上传到服务器上,一下子,android就访问不到数据了,因为还是一个小白,所以一开始就在安卓端找问题,安卓端一直报volleryError的错误,后来网上查了一下,说是服务器的问题,于是我就用postman模拟post发送数据,发现出现500 internal server error。然后又上网查了一下,说如果是新上传的文件,可能是权限问题,文件和根目录要0755,HTML等是0644,我看了一下文件的权限没有问题,甚至试了一下将文件的权限改为0777也没有用。后来无意中又看到可以在入口文件中加入

error_reporting(E_ALL);

ini_set('display_errors', '1');

打印出具体错误如下:

Fatal error: Uncaught think\exception\ErrorException: error_log(/usr/local/apache2/htdocs/XY/XY_APP_API/runtime/log/18_04_03.log): failed to open stream: Permission denied in /usr/local/apache2/htdocs/XY/XY_APP_API/thinkphp/library/think/log/driver/File.php:79 Stack trace: #0 [internal function]: think\Error::appError(2, 'error_log(/usr/...', '/usr/local/apac...', 79, Array) #1 /usr/local/apache2/htdocs/XY/XY_APP_API/thinkphp/library/think/log/driver/File.php(79): error_log('[ 2018-04-03T11...', 3, '/usr/local/apac...') #2 /usr/local/apache2/htdocs/XY/XY_APP_API/thinkphp/library/think/Log.php(136): think\log\driver\File->save(Array) #3 /usr/local/apache2/htdocs/XY/XY_APP_API/thinkphp/library/think/Error.php(84): think\Log::save() #4 [internal function]: think\Error::appShutdown() #5 {main} thrown in /usr/local/apache2/htdocs/XY/XY_APP_API/thinkphp/library/think/log/driver/File.php on line 79,

看到了是runtime的日志文件没有权限,于是将日志文件赋予0777的权限,问题解决了。