Solution for nginx unable to start php: 1. Find the nginx configuration file; 2. Add the content "fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;"; 3. Restart nginx.
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.
nginx What should I do if I cannot start php?
nginx installation is complete and cannot parse php solution
After nginx is installed, it is found that php code cannot be parsed. The current solution is as follows
Method 1
Find the nginx configuration file, add the configuration as shown below (shown in the screenshot), the location of my configuration file is /etc/nginx/sites-available/default
location ~ \.php$ { root /var/www/html; include snippets/fastcgi-php.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
After modifying the nginx configuration file, restart nginx to take effect
/etc/init.d/nginx restart
Method 2
nginx php fpm implementation
Install php7.4-fpm
sudo apt-get install php7.4-fpm
Check whether php-fpm is turned on
ps -ef|grep php
Find php7.4-fpm.sock
Go back to the root directory and execute find ./ -name php7.4-fpm.sock
Find php7.4-fpm.sock The location, as shown in the following directory, is the location of php7.4-fpm.sock. We copy the location of php7.4-fpm.sock and modify the nginx configuration file.
/run/php/php7.4-fpm.sock
Configure the following screenshot unix:php7.4-fpm.sock path location
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
After modifying the nginx configuration file, restart nginx to take effect
/etc/init.d/nginx restart
Restart or start php7.4-fpm as follows
/etc/init.d/php7.4-fpm restart /etc/init.d/php7.4-fpm start
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What should I do if nginx cannot start php?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
