PHP-FPM and Nginx: 502 Bad Gateway

后端 未结 15 1782
闹比i
闹比i 2021-01-29 18:35

Configuration

  • Ubuntu Server 11.10 64 bit
  • Amazon AWS, Ec2, hosted on the cloud
  • t1.micro instance

Before I write an

15条回答
  •  梦毁少年i
    2021-01-29 18:54

    In your NGINX vhost file, in location block which processes your PHP files (usually location ~ \.php$ {) through FastCGI, make sure you have next lines:

    proxy_buffer_size          128k;
    proxy_buffers              4 256k;
    proxy_busy_buffers_size    256k;
    fastcgi_buffer_size        16k;
    fastcgi_buffers            4 16k;
    

    After that don't forget to restart fpm and nginx.


    Additional:

    NGINX vhost paths

    • /etc/nginx/sites-enabled/ - Linux
    • '/usr/local/etc/nginx/sites-enabled/' - Mac

    Restart NGINX:

    • sudo service nginx restart - Linux
    • brew service restart nginx - Mac

    Restart FPM:

    Determine fpm process name: - systemctl list-unit-files | grep fpm - Linux - brew services list | grep php - Mac

    and then restart it with:

    • sudo service restart - Linux
    • brew services restart - Mac

提交回复
热议问题