Nginx Cannot parse php file

Source: Internet
Author: User

Original address: Nginx cannot parse the PHP solution
0x00: Problem description

When you access the *.php file, the contents of the file are not displayed, but the files you want to access are downloaded directly, such as index.php.


0x01: Solutions

:: Find nginx configuration file, modify file to support PHP

Profile location under:/etc/nginx/sites_available/If you have not created any other configuration files, there should be a default profile named "Default".


1. Open the configuration file to find the following contents 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, then remove the corresponding comments.

3. Restart Nginx to access the page.

sudo service nginx restart

4. If 503 errors occur again, please install PHP5-FPM and visit again

sudo apt-get install PHP5-FPM




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.