Home  >  Article  >  Backend Development  >  What should I do if nginx cannot parse php files?

What should I do if nginx cannot parse php files?

藏色散人
藏色散人Original
2021-09-10 09:23:556390browse

Solutions to why nginx cannot parse php files: 1. Install nginx; 2. Configure the content of the nginx.conf file to "unix:/run/php-fpm/php-fpm.sock..."; 3. , just restart nginx.

What should I do if nginx cannot parse php files?

The operating environment of this article: linux5.9.8 system, PHP7.1 version, DELL G3 computer

Why can’t nginx parse php files? manage?

nginx cannot parse php files under Linux

1. Prerequisite

nginx has been installed and can access html files

2.Problem

When accessing the .php file, it will be downloaded by default, or it will prompt "File not found."

3. Solution

Configure the nginx.conf file

location ~ \.php$ {
            root           /mnt/wind/www;                                    #根目录配置正确
            fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;                   #跟php-fpm的监听端口一样         
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
}

Restart nginx.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if nginx cannot parse php files?. 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