Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

240
Visualizações
Configuration nginx 1.18 with php-fpm7.4

I want to run php under nginx, I have some difficulties. I'm almost done, however, I have an error 502, I don't know why.

I have Nginx 1.18, php 7.4.x with fpm. I created a php file in: /usr/share/nginx/html/info.php, however when I am on it, I have an error 502. Here is the file I have for the default conf:

server {

    listen 80;
    root /usr/share/nginx/html;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name localhost;

    location / {
            try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location ~ /\.ht {
            deny all;
    }

}

I have seen this line in some cases, however when I do "nginx -t" it fails.

include snippets / fastcgi-php.conf;

I looked carefully, everything works locally, everything works. I do not understand.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

In your post above you have server_name example.com. Check if you have the right server name there. Also, make sure your application server is running because nginx is unable to reach that's why you are seeing 502

over 4 years ago · Santiago Trujillo Relatório

0

The problem is having more than 1 config file in /etc/php/7.4/fpm/pool.d

   usr@server:/etc/php/7.4/fpm/pool.d$ ls
      www.conf  foor-php-fpm.conf  bar-php-fpm.conf.bak
   

Solution

Step 1: Remove or rename any other .conf files and leave only www.conf

usr@server:/etc/php/7.4/fpm/pool.d$ sudo mv other-php-fpm.conf other-php-fpm.conf.bak2

Step 2: systemctl restart php7.4-fpm.service

Done!

user@server:~$ systemctl status php7.4-fpm.service

    ● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
         Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
         Active: active (running) since Thu 2020-12-31 16:16:22 UTC; 6s ago
           Docs: man:php-fpm7.4(8)
        Process: 381508 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.4/fpm/pool.d/www.conf 74 (code=exited, status=0/SUCCESS)
       Main PID: 381487 (php-fpm7.4)
         Status: "Ready to handle connections"
          Tasks: 3 (limit: 4568)
         Memory: 12.1M
         CGroup: /system.slice/php7.4-fpm.service
                 ├─381487 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
                 ├─381506 php-fpm: pool www
                 └─381507 php-fpm: pool www

This solution applies to php-fpm-7.2 as well.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda