Rebooted linode now 502 Bad Gateway

Linode has been running fine for around 80 days. Shut down today to take advantage of new linode disk space, resized disk, then booted back up and now all php sites show 502 Bad Gateway. Nginx is running because plain html sites work fine, none of the php or webmail sites though. I restarted php-fpm, reload webpage and same error.

Php config files all look ok, same for nginx. Iptables looks as it did before. Fail2ban sent me some start and stop messages such as this:

Hi,
The jail ssh has been started successfully.
Regards,
Fail2Ban
Hi,
The jail ssh has been stopped successfully.
Regards,
Fail2Ban

I got one of these groups of messages for ssh, ssh-dos, postfix, dovecot, nginx, nothing for php so this appears to just be the rules stoping and starting back up, they appear in iptables.

I don't see the php-fpm users in htop like I usually do.

I've been able to restart php-fpm service fine in the past.

I see this in php-fpm log:

[21-Aug-2013 21:01:19] ERROR: unable to bind listening socket for address '/var/run/php5-fpm/mydomain.socket': No such file or directory (2)
[21-Aug-2013 21:01:19] ERROR: FPM initialization failed

Any ideas on what I can check?

4 Replies

This was the issue:

https://github.com/vernak2539/babble.by … t.markdown">https://github.com/vernak2539/babble.byvernacchia/blob/master/_posts/2013-05-23-dealing-with-nginx-and-php5-fpm-on-reboot.markdown

/var/run/php5-fpm/ was not there after reboot.

To create this directory on reboot it says to do this:

To make sure this doesn't happen the next time you reboot your server, I would checkout this comment.

All you have to do is edit the /etc/init.d/php5-fpm file, and add the stuff below.

// add at top by all your other variables
SOCKETDIR = /var/run/php5-fpm

// then inside do_start()
// replace users as you see fit
[ -d $SOCKETDIR ] || install -m 755 -o www-data -g root -d $SOCKETDIR

But what if I have a different socket name for each site hosted and each run as a different user, will that single line work with "www-data -g root"?

@jgjh151:

This was the issue:

https://github.com/vernak2539/babble.by … t.markdown">https://github.com/vernak2539/babble.byvernacchia/blob/master/_posts/2013-05-23-dealing-with-nginx-and-php5-fpm-on-reboot.markdown

/var/run/php5-fpm/ was not there after reboot.

To create this directory on reboot it says to do this:

To make sure this doesn't happen the next time you reboot your server, I would checkout this comment.

All you have to do is edit the /etc/init.d/php5-fpm file, and add the stuff below.

// add at top by all your other variables
SOCKETDIR = /var/run/php5-fpm

// then inside do_start()
// replace users as you see fit
[ -d $SOCKETDIR ] || install -m 755 -o www-data -g root -d $SOCKETDIR

But what if I have a different socket name for each site hosted and each run as a different user, will that single line work with "www-data -g root"?

With php-fpm, you should only have one socket, and one user.

@kbar:

@jgjh151:

This was the issue:

https://github.com/vernak2539/babble.by … t.markdown">https://github.com/vernak2539/babble.byvernacchia/blob/master/_posts/2013-05-23-dealing-with-nginx-and-php5-fpm-on-reboot.markdown

/var/run/php5-fpm/ was not there after reboot.

To create this directory on reboot it says to do this:

To make sure this doesn't happen the next time you reboot your server, I would checkout this comment.

All you have to do is edit the /etc/init.d/php5-fpm file, and add the stuff below.

// add at top by all your other variables
SOCKETDIR = /var/run/php5-fpm

// then inside do_start()
// replace users as you see fit
[ -d $SOCKETDIR ] || install -m 755 -o www-data -g root -d $SOCKETDIR

But what if I have a different socket name for each site hosted and each run as a different user, will that single line work with "www-data -g root"?

With php-fpm, you should only have one socket, and one user.

What? Isn't one of the awesome things about PHP-FPM that you can give users their own pool and run as their own user?

I've fought with this on occasion, but ended up just doing TCP sockets. No real downside, as far as I can tell.

And indeed… with php-fpm, you should have as many pools (and thus as many users and sockets) as you do applications. None of them should be running as www-data. That's the point.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct