Home >Backend Development >PHP Problem >What should I do if nginx cannot parse php files?
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.
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!