1

I have apache running just fine on start up and manually using /etc/init.d/apache2 start and I'm ok with that, but one of the server managers is used to using the service command, and for some reason apache will not run properly through service.

If I run it directly, I get:

Start
...[OK]

Stop
...[OK]

Help
Usage: /etc/apache2/bin/httpd [-D name] [-d directory] [-f file]
...

but when I try to run it through the service command, I get:

Start
start: Job failed to start

Stop
stop: Unknown instance:

Help
Usage: /etc/apache2/bin/httpd [-D name] [-d directory] [-f file]
...

I previously thought that they were pointing at different executables, but based on the usage output from help, they are both pointing at /etc/apache2/bin/apachectl, which in turn points at /etc/apache2/bin/httpd. Also this indicates to me that service can't find the running httpd process (maybe because it's called httpd instead of apache2).

Why would these two methods that are invoking the same exe (it's actually a script, but that shouldn't matter) have different results?

  • Why aren't you using apachectl ? – Xavier Lucas Oct 21 '14 at 14:19
  • I am, edited my question. – TheBat Oct 21 '14 at 14:24
  • Can you post the output of the /var/log/apache2/error.log ? What does it say ? – deppfx Oct 21 '14 at 14:49
  • The only thing in the log is some php warnings that are completely irrelevant. When I attempt to start/stop/restart, nothing additional is printed. – TheBat Oct 21 '14 at 15:17
  • I may have found the problem, it seems that service actually points at a script managed by upstart in the init directory, while the script I was manually using in init.d is used by sysvinit. So I was still getting the start on boot. I'll write up a real answer if I can fully figure out the problem. – TheBat Oct 21 '14 at 16:02
1

After some research and messing around with files I figured out the problem.

The issue for me was with Upstart's backwards compatibility with sysvinit causing a transparent conflict between two files. Upstart supports scripts in the /etc/init.d directory with backwards compatibility support for sysvinit, since that is the old directory that sysvinit used for scripts. Upstart however uses /etc/init/ for it's scripts. The intended usage is to have a script in one or the other directory. My issue came down to me having both (I'm still not sure how the /etc/init/ script got there). Since the script in /etc/init was not a functional script (it was pointing at the wrong apache exe), it failed on boot, which was fine since the one in init.d was running. But once I tried to run it through service, the error became visible.

I deleted /etc/init/apache2.conf and now service apache2 points correctly at the script in init.d like I want it to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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