Ubuntu Tips: 显示php错误 How do you display PHP error messages?
  4yu2JdefgeRW 2023年11月02日 38 0


Like me you maybe using an Ubuntu computer running Apache, MySQL and PHP to develop websites. When developing it is important to see error messages to debug your code. On occasion I have installed PHP on to Ubuntu computers and by default errors are not displayed. As this is not a production web server I updated the php.ini file to display errors. In this post I explain how I updated the php.ini to display error messages and aid debugging.

Step 1 - Open php.ini

Start by opening a new terminal window to open the php.ini file. Modifying the php.ini will allow you to tunes the setting to enable more descriptive error messages, logging, and better performance.

 

Enter the following command to begin editing php.ini. This will require the sudo command and therefore administrator privileges.



sudo gedit /etc/php5/apache2/php.ini



Step 2 - Display Errors

Now scroll down through the file until you find the following line.



display_errors = Off


Once you have found the display_errors line replace the parameter 'Off' with 'On'. Once you have made the swap save the file and then exit the editor.



display_errors = On



Step 3 - Restart Apache

Now that you have made the change to the php.ini file you need to restart the Apache web server to effect the change. To do this enter the command below into your terminal window to restart the service. Once the service has restarted you will be able to see error message in your PHP scripts instead of blank white pages.



sudo /etc/init.d/apache2 restart



Links


How To Display PHP Errors In My Script Code When Display_errors Is Disabled



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
4yu2JdefgeRW