Home >Backend Development >PHP Problem >What to do if PHP cannot be parsed in Nginx+PHP environment

What to do if PHP cannot be parsed in Nginx+PHP environment

coldplay.xixi
coldplay.xixiOriginal
2020-07-29 15:23:043046browse

The solution to the problem that PHP cannot be parsed in the Nginx PHP environment: first open the file and add the relevant code; then restart the nginx service after the modification is completed, the code is [nginx -s reload]; finally re-parse the PHP page. .

What to do if PHP cannot be parsed in Nginx+PHP environment

Solution to PHP failure to parse in Nginx PHP environment:

Change nginx default fastcgiparams configuration file

1. Open the file with the following command

vi /etc/nginx/fastcgi_params

2. Add the following two lines of code at the end of the file

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  
fastcgi_param PATH_INFO                $fastcgi_script_name;

PS: Note that $document_root is the root directory of the project web page, such as mine The root directory is: /var/www

3. After the modification is completed, restart the nginx service

    nginx -s reload

Finally, re-parse the php page and you can find the problem solved.

Related learning recommendations: PHP programming from entry to proficiency

The above is the detailed content of What to do if PHP cannot be parsed in Nginx+PHP environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn