Home > Operation and Maintenance > Nginx > How to solve nginx cannot start php

How to solve nginx cannot start php

WBOY
Release: 2023-05-22 10:25:05
forward
1893 people have browsed it

Solution to nginx being 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.

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

How to solve nginx cannot start php

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

How to solve nginx cannot start 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

How to solve nginx cannot start php

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

The above is the detailed content of How to solve nginx cannot start php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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