Home > Backend Development > PHP Problem > What should I do if nginx cannot start php?

What should I do if nginx cannot start php?

藏色散人
Release: 2023-03-17 13:46:02
Original
1636 people have browsed it

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.

What should I do if nginx cannot start php?

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;
}
Copy after login

After modifying the nginx configuration file, restart nginx to take effect

/etc/init.d/nginx restart
Copy after login

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
Copy after login

Configure the following screenshot unix:php7.4-fpm.sock path location

 fastcgi_pass unix:/run/php/php7.4-fpm.sock;
Copy after login

After modifying the nginx configuration file, restart nginx to take effect

/etc/init.d/nginx restart
Copy after login

Restart or start php7.4-fpm as follows

/etc/init.d/php7.4-fpm restart
/etc/init.d/php7.4-fpm start
Copy after login

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!

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