Home > Article > Backend Development > What to do if nginx does not parse php
The solution to nginx not parsing php: first find the nginx configuration file; then remove the corresponding comments; then restart nginx and visit the page; finally reinstall php5-fpm and visit again.
Recommended: "PHP Video Tutorial"
Nginx cannot parse php files
0x00: Problem description
When accessing the *.php file, the content of the file is not displayed but the file to be accessed is directly downloaded, such as index.php.
0x01: Solution
:: Find the nginx configuration file and modify the file to support php
The configuration file location is: /etc/nginx/sites_available/ below, If you have not created any other configuration files, there should be a default configuration file named "default".
1. Open the configuration file and find the following content in the file:
location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have “cgi.fix_pathinfo = 0;” in php.ini # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
2. If you find that the above content is commented out, remove the corresponding comment.
3. Restart nginx and visit the page.
sudo service nginx restart
4. If a 503 error occurs when accessing again, please install php5-fpm and access
sudo apt-get install php5-fpmagain.
The above is the detailed content of What to do if nginx does not parse php. For more information, please follow other related articles on the PHP Chinese website!