Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with OpenID
Advertise on LowEndTalk.com

In this Discussion

Nginx 502 Bad Gateway

Nginx 502 Bad Gateway

joodlejoodle Member
edited September 2012 in General

After i rebooted my server, i get the nginx error: 502 Bad Gateway

How can i fix that?

Free Ad-Blocking DNS: 94.177.230.107 || 500/500 Fiber Home Connection, woah!

Comments

  • maybe php-cgi / php-fpm is not running?

    service php-cgi start service php-fpm start

    The Original Daniel.

  • i started php-cgi but still showing that error

    Here is a small error log:

    2012/09/14 20:17:30 [crit] 810#0: *24 connect() to unix:/var/run/www/php.sock failed (2: No such file or directory) while connecting to upstream, client: XXXXXX, server: XXXXXX, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/var/run/www/php.sock:", host: "XXXXX"

    Free Ad-Blocking DNS: 94.177.230.107 || 500/500 Fiber Home Connection, woah!

  • AsadHaiderAsadHaider Member
    edited September 2012

    @joodle PHP-FPM permissions to that file? http://www.ruby-forum.com/topic/4236563

  • @AsadHaider i dont use php-fpm

    Free Ad-Blocking DNS: 94.177.230.107 || 500/500 Fiber Home Connection, woah!

  • Try to create folder /var/run/www/ and set permision to www-data:www-data

    Try this:D

    mkdir /var/run/www/; chown -R www-data:www-data /var/run/www

    Then restart php-cgi.

    SellSSL.com - Comodo InstantSSL with Free EV Upgrade for $29 USD!

    Cartika.com - 512MB, 200GB HDD, 10TB BW for $5 USD - Order via my aff link!

    Thanked by 1joodle
  • @giang you are my hero!

    Free Ad-Blocking DNS: 94.177.230.107 || 500/500 Fiber Home Connection, woah!

    Thanked by 1giang
  • I was right with the permissions part :P

  • gianggiang Member
    edited September 2012

    @joodle said: @giang you are my hero!

    Glad that could help you :D It seems you are using LowEndAdmin's script :D

    SellSSL.com - Comodo InstantSSL with Free EV Upgrade for $29 USD!

    Cartika.com - 512MB, 200GB HDD, 10TB BW for $5 USD - Order via my aff link!

  • @giang yep im using that script

    Free Ad-Blocking DNS: 94.177.230.107 || 500/500 Fiber Home Connection, woah!

  • @tinyray said: @joodle: why not php-fpm?

    php-cgi works fine for me, so why should i choose php-fpm?

    Free Ad-Blocking DNS: 94.177.230.107 || 500/500 Fiber Home Connection, woah!

  • It's far better, for one.

    -- BOFH

  • WilliamWilliam Member, Provider

    yea, and it runs as own process

    AS203661 - [email protected] - /24 from 50$/mo 4 Israel locations: Rosh HaAyin x2 (Central) - Petah Tikva (Central) - Tel Aviv (Coast)

  • gianggiang Member
    edited September 2012

    @joodle said: @giang yep im using that script

    I got this problem with LEA's script too :P That's why I could figure out how to fix it. This only happens on Ubuntu OS :D

    @tinyray said: @joodle: why not php-fpm?

    I did test php-fpm and php-cgi on my VPS, php-cgi processed Wordpress faster than php-fpm a little bit (about .2s)

    SellSSL.com - Comodo InstantSSL with Free EV Upgrade for $29 USD!

    Cartika.com - 512MB, 200GB HDD, 10TB BW for $5 USD - Order via my aff link!

  • you must use temp folder for php socket it's better, edit php-cgi config and change this line "unix:/var/run/www/php.sock" to this:

    unix:/tmp/php.sock and chown tmp directory : chown -R www-data:www-data /tmp

    then restart nginx + php-cgi :)

  • @giang said: php-cgi processed Wordpress faster than php-fpm a little bit (about .2s)

    Probably because php-fpm needs more time to spawning process / children. Try static instead of dynamic or ondemand

  • WilliamWilliam Member, Provider

    chown the whole tmp directory to www-data? Not a great idea...

    AS203661 - [email protected] - /24 from 50$/mo 4 Israel locations: Rosh HaAyin x2 (Central) - Petah Tikva (Central) - Tel Aviv (Coast)

  • @William said: chown the whole tmp directory to www-data?

    tmp folder is 777 already?

    SellSSL.com - Comodo InstantSSL with Free EV Upgrade for $29 USD!

    Cartika.com - 512MB, 200GB HDD, 10TB BW for $5 USD - Order via my aff link!

Sign In or Register to comment.