Home > Backend Development > PHP Problem > What should I do if index.php is not parsed when accessing it?

What should I do if index.php is not parsed when accessing it?

藏色散人
Release: 2023-03-15 06:16:01
Original
2959 people have browsed it

The solution to accessing index.php without parsing is to configure a piece of code in the nginx server as "location ~ \.php$ {try_files $uri =404;fastcgi_split_path_info ^(. .php)...}" That’s it.

What should I do if index.php is not parsed when accessing it?

The operating environment of this article: Windows7 system, PHP5 version, DELL G3 computer

What should I do if index.php is not parsed when accessing it?

nginx server does not parse PHP when accessing, and directly downloads the PHP file

When configuring the server, this situation sometimes occurs. Map the domain name to the directory and access the The domain name directly downloads the index.php file. How to solve this situation?

location ~ \.php$ {
        try_files $uri =404; #增加
        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; #反注释
#       include snippets/fastcgi-php.conf;
#
#       # With php5-cgi alone:
#       fastcgi_pass 127.0.0.1:9000;
#       # With php5-fpm:
#       fastcgi_pass unix:/var/run/php5-fpm.sock;
}
Copy after login

Just configure this piece of code in the nginx server to parse PHP. The purpose of this code is to automatically jump to php5-fpm to parse the file when accessing a php file.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if index.php is not parsed when accessing it?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template