1. 程式人生 > >將本地TP5專案檔案上傳到lamp環境上出現500錯誤

將本地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的許可權,問題解決了。