Score:0

How to connect php-fpm with nginx?

be flag

I have a server that uses Nginx and PHP-FPM (PHP v7.4). It was working as well, I executed the following command for some reasons:

apt-get --purge remove php-common

After that, I executed this:

apt-get install php-common php-mysql php-cli

Commands executed successfully, but I get 502 error when I want to access websites on the servers:

enter image description here

It should be noted, there are several projects on this server. And I have nothing inside /etc/nginx/sites-available. I have all configurations under /etc/nginx/conf.d. See:

enter image description here

Each of them is a project. Now, I guess I need to set to PHP-FPM to use conf.d instead of sites-available. Any idea how can I do that?

Could you please help me how can I debug it?

Score:0
cn flag

You must make sure you have reinstalled the required software specifically the php-fpm

sudo apt-get install php-fpm

Then start the php fpm as follows

sudo systemctl start php7.4-fpm
sudo systemctl enable php7.4-fpm

Also make sure the php-fpm is properly setup in the server.conf of nginx. Which as per you must be OK as you havent changed it and it was working before your purge commands

server {
    listen 80;
    server_name example.com;
    root /var/www/example.com;

    location / {
        index index.php index.html;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.