Solution to PHP not being able to be parsed after nginx installation is complete

Solution to PHP not being able to be parsed after nginx installation is complete

After installing nginx, I found that I could not parse the PHP code. Now the solution is as follows

Method 1

Find the nginx configuration file and add it as shown below (pictured in the screenshot). My configuration file location 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

Implementation of nginx+php+fpm

Install php7.4-fpm

sudo apt-get install php7.4-fpm

Check whether php-fpm is enabled

ps -ef | grep php

Find php7.4-fpm.sock

Go back to the root directory and execute find ./ -name php7.4-fpm.sock

Find the location of php7.4-fpm.sock. The following directory shows 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

This is the end of this article about how to solve the problem that nginx cannot parse PHP after installation. For more related content about nginx cannot parse PHP, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of Nginx anti-hotlinking, Nginx access control and Nginx parsing PHP configuration
  • How to connect PHP to Nginx server and parse Nginx log

<<:  N ways to center elements with CSS

>>:  Summary of JavaScript Timer Types

Recommend

Bootstrap 3.0 study notes buttons and drop-down menus

The previous article was a simple review of the B...

Some small methods commonly used in html pages

Add in the <Head> tag <meta http-equiv=&q...

Linux installation MySQL tutorial (binary distribution)

This tutorial shares the detailed steps of instal...

Web Design: Web Music Implementation Techniques

<br />When inserting music into a web page, ...

Detailed process of installing the docker plugin in IntelliJ IDEA (2018 version)

Table of contents 1. Development Environment 2. I...

Summary of tips for making web pages

Preface This article mainly summarizes some of th...

How to install Oracle_11g using Docker

Install Oracle_11g with Docker 1. Pull the oracle...

Mysql 8.0 installation and password reset issues

Mysql 8.0 installation problems and password rese...

Methods and steps for deploying go projects based on Docker images

Dependence on knowledge Go cross-compilation basi...

Analysis and solutions to problems encountered in the use of label tags

I used the label tag when I was doing something re...

JS+AJAX realizes the linkage of province, city and district drop-down lists

This article shares the specific code of JS+AJAX ...

Implementation of HTML command line interface

HTML Part Copy code The code is as follows: <!D...

How to deploy SpringBoot project using Docker

The development of Docker technology provides a m...

Detailed explanation of MySQL database binlog cleanup command

Overview Today I will mainly share how to correct...