Solution: 1. Configure the display_errors and error_reporting parameters in the php.ini file; 2. Configure the httpd.conf file of apache, and then restart apache; 3. Call the ini_set() function to output the error prompt, and then Just solve it.
#php After a novice has set up the development environment in the early stage, when a syntax error occurs during development, the server returns 500 (server internal error) instead of returning an error message. At this time, you need to make some configurations in the development environment to help you quickly find the cause of the problem, locate the problem, and solve the problem.
1. Find the php configuration file /etc/php.ini
Configuration parameter value:
display_errors = On error_reporting = E_ALL | E_STRICT
2. Restart the apache service
service httpd restart
At this time, the browser can already output error messages.
3. Configure apache/etc/httpd/conf/httpd.conf
Add two lines at the end of the apache configuration file:
php_flag display_errors on php_value error_reporting 2039
4. Restart apache
The setting of parameters in php.ini can also be done in php code.
Call:
Call the ini_set() function
//开启php.ini中的display_errors指令 ini_set('display_errors',1); //通过error_reporting()函数设置,输出所有级别的错误报告 error_reporting(E_ALL);
This can be used dynamically to output errors in the specified php file.
Related recommendations: PHP tutorial
The above is the detailed content of How to solve php server 500 error?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Notepad++7.3.1
Easy-to-use and free code editor
