Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running PHP-FPM and Nginx, occasionally, for whatever reason, I have to reboot the server. Once the server is running again, the nginx service automatically starts, however, PHP-FPM does not. This can be seen when I run the command sudo /etc/init.d/php-fpm restart immediately after a reboot and get the result:

$ sudo /etc/init.d/php-fpm restart
Stopping php-fpm:                                          [FAILED]
Starting php-fpm:                                          [  OK  ]

Is this expected behaviour? What is the best way to make PHP-FPM automatically start? Is there a config option anywhere, or do I have to add the command to one of the Linux startup scripts?

Thanks.

share|improve this question
    
Which linux distribution are you using? How did you installed php-fpm? From a package or from sources? – Tonin Dec 20 '12 at 16:20
    
It's running on an Amazon EC2 Linux instance, PHP-FPM was installed using yum install -y php-fpm – SteveEdson Dec 20 '12 at 16:25
up vote 13 down vote accepted

So set it up to start at boot:

chkconfig php-fpm on
share|improve this answer
    
As simple as that, brilliant! Cheers – SteveEdson Dec 20 '12 at 16:27

I just ran into this very problem on Ubuntu 16.04 and I'm leaving my answer here for future users from Google who stumble onto the problem. Since chkconfig is mostly specific to CentOS, it obviously doesn't exist on Ubuntu. Apparently, to get a custom-built PHP (php-fpm SAPI) to start at boot under systemd, which is new to Ubuntu 16.04 (previously, Upstart), it needs to be registered with the system beyond just dropping the init.d script into /etc/init.d/. To register the script, I ran:

update-rc.d php-fpm defaults

A reboot and subsequent ps aux confirmed that php-fpm was indeed starting at boot. It was also added to /etc/init.d/.depend.start.

Other thoughts: Ubuntu Upstart was nice enough so that I never had to run update-rc.d after placing an init.d script - it just worked. Completely forgot about that command.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.