Freebsd – Apache not running from rc.d on FreeBSD

apache-2.2freebsd

I'm using FreeBSD 8.3 and Apache 2.2. I didn't install Apache from ports, instead compiled it from source because I wanted to move the binary and configuration to a different path (I'm centering all of the major production daemons and their configurations in a single place). In any case, I based the /usr/local/etc/rc.d/apache22 file on one from a different server where it was installed from ports, I only modified the binary and config paths within.

I can manually execute it with /usr/local/etc/rc.d/apache22 start, however even with apache22_enable="YES" in /etc/rc.conf it fails to start. All permissions and ownership are identical to the other server where it works.

What am I missing and is there a way to debug this kind of thing?

Best Answer

If you run /usr/local/etc/rc.d/apache22 rcvar it will tell you the variable it's looking at, and what it's set to in rc.conf, but if it's starting correctly with start (as opposed to onestart or forcestart) it should start correctly at boot.

If that doesn't give you an immediate answer and solution it's probably easier if you forget about basing your scripts on another one (the Apache script has some extra complexity), and instead start at the beginning with this guide to practical rc.d scripting.
If you follow those instructions you will have to go out of your way to create a non-working script.
As a bonus you'll learn all about how the rc.d sequence works, and be better able to understand and troubleshoot it in the future.