Home >Operation and Maintenance >Nginx >How to solve the error when nginx opens php
Check whether the Nginx server is compatible with the PHP running environment
Before proceeding to the next step, you You need to make sure that the Nginx server is compatible with your PHP running environment. You can run some test scripts to see if the Nginx server and PHP environment work together. If the test script runs normally, it means that the Nginx server is compatible with the PHP environment. Otherwise, you need to follow the next steps to solve this problem.
Check whether the Nginx server has been correctly configured
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }In this example, you need to make sure that the fastcgi_pass option has the correct IP address as well as the port number. You also need to make sure the fastcgi_index option points to the correct filename.
Check whether the PHP running environment is installed correctly
Check if the PHP module is installed correctly
php -mIn this command, the -m option is used to view the installed PHP modules. If the PHP module is not installed, you need to install the missing PHP module.
Check whether the Nginx server has correctly parsed the PHP file
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; error_log /var/log/nginx/php.error.log; }In this example, you need to point the error_log option to the correct path and determine whether the path is set to be writable.
The above is the detailed content of How to solve the error when nginx opens php. For more information, please follow other related articles on the PHP Chinese website!