Opened 12 years ago

Last modified 10 months ago

#36101 new defect

apache2 @2.2.22_2 startup item

Reported by: grrr@… Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: mountainlion Cc: cooljeanius (Eric Gallager), ctreleaven (Craig Treleaven), lagrave+bugs+macosforge.org@…, jeabraham, Schamschula (Marius Schamschula), pixilla (Bradley Giesbrecht), alphanull (alphanull), yugaego (YE)
Port: apache2

Description

On OS X 10.8.1 after every reboot apache2 is not starting for me, and I have activated the LaunchDaemon.

$ sudo port load apache2
org.macports.apache2: Already loaded

Still no httpd.

Running

$ sudo apachectl start

successfully starts Apache, until reboot.

I've tried uninstalling and reinstalling apache2, running the launchctl load/unload commands on org.macports.apache2.plist, and checked my Apache config with apachectl configtest. Other MacPorts startup items work (MySQL5, dnsmasq), just not Apache.

Change History (18)

comment:1 Changed 12 years ago by ryandesign (Ryan Carsten Schmidt)

Keywords: mountainlion added; apache2 removed
Owner: changed from macports-tickets@… to ryandesign@…

Interesting. Since upgrading to Mountain Lion apache2 was also not starting for me and I had not yet spent the time to investigate why. If anybody knows why please let me know. Does the console say anything about it?

comment:2 Changed 12 years ago by grrr@…

I don't see anything in the console, even after changing launchctl's log level (sudo launchctl log level debug).

comment:3 Changed 12 years ago by grrr@…

I apparently fixed this when changing my local dnsmasq config. In /etc/hosts I added my servername (gala) to the loopback entry:

127.0.0.1   localhost gala

and then I changed ServerName in /opt/local/apache2/conf/httpd.conf to match:

ServerName gala

Apache now starts at boot for me.

comment:4 Changed 11 years ago by j+macports@…

I've had this same problem on Lion with various versions of apache2 for many months. Nothing obvious in the Console related to either launchd/apache/httpd.

Ryan, if there's anything I can do or test or any logs I can try and get to help you let me know.

Last edited 11 years ago by j+macports@… (previous) (diff)

comment:5 Changed 11 years ago by j+macports@…

I'm starting to wonder if the reason apache2 fails to actual start despite the fact that launchctl shows that the port has loaded is that the DNS is not fully operational at the time apache2 tries to start and thus fails because of servername mis-match (my machine is it's own DNS server with an internal-only domain name). Does anyone know if there is a good way to somehow delay when the apache2 launchd item tries to execute?

comment:6 Changed 11 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:7 Changed 11 years ago by ctreleaven (Craig Treleaven)

Cc: ctreleaven@… added

Cc Me!

comment:8 Changed 11 years ago by ctreleaven (Craig Treleaven)

Another workaround is to 'sudo port unload apache2' and then 'sudo port load apache2'.

comment:9 Changed 10 years ago by lagrave+bugs+macosforge.org@…

Cc: lagrave+bugs+macosforge.org@… added

Cc Me!

comment:10 Changed 9 years ago by jeabraham

Cc: jea@… added

Cc Me!

comment:11 Changed 6 years ago by jmroot (Joshua Root)

Cc: Schamschula pixilla added

comment:12 Changed 4 years ago by alphanull (alphanull)

I have the same problem since years now, and it is quite annoying! Would be nice if we could solve this once and for all, since there seem to be more users affected. I also have some local DNS Server on my router, so this might be a common culprit? All possible workarounds (editing hosts file, delayed startup like described here: https://stackoverflow.com/questions/2042992/macports-apache2-stopped-launching-on-boot) did not work for me. Of course I am willing to help, so if there is anything I can do / test please let me know.

And if there is only a "hacky" workaround for the moment, like stopping / restarting httpd automatically by some script, than having it to do manually after each restart, I will gladly take it.

comment:13 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: alphanull added

alphanull, which macOS version are you using? Does the apache error log show anything of note after a system startup -- anything to indicate that it started and then stopped due to some problem?

comment:14 Changed 4 years ago by alphanull (alphanull)

First of all, thanks for responding so quickly!

So I am using Catalina 10.15.5 right now, but the problem bugs me since at least High Sierra (also on another machine) and I actually hoped it would go away with the upgrade ....

So I cleared both access_log and error_log and restarted the machine. Directly after logging in there were no messages whatsoever (file weren't even recreated), and when I do the typical "unload / load" dance, I get this in error_log:

[Thu Jun 18 13:31:27.234114 2020] [mpm_event:notice] [pid 955:tid 4466769344] AH00489: Apache/2.4.43 (Unix) OpenSSL/1.1.1g configured -- resuming normal operations
[Thu Jun 18 13:31:27.234447 2020] [core:notice] [pid 955:tid 4466769344] AH00094: Command line: '/opt/local/sbin/httpd'

Doesn't look like there is anything wrong, but still it does not work correctly. Doing "apachectl -t" give me "Syntax OK" which of course is also nothing suspicious.

Any other idea where to look?

comment:15 Changed 4 years ago by alphanull (alphanull)

Next, I tried to start over from scratch, with a completely new installation. And look, it worked! So I dug through my config step by step - which is relatively complex - until I found the culprit. Turns out it was some includes in some of my vhosts (which share a lot of the same basic configuration, so I thought includes would prevent redundant configs):

Include  /Volumes/Daten/Users/Frank/Sites/projects/test/apache.include.conf

It seems it does not matter what is inside those included files, it won't work even when trying to include a completely empty file! But still I have no idea why this behavior occurs, and why Apache fails completely silently, with no error log at all. Also in this case Apache does not only fail on those vhosts, but also with anything else (even if my oher vhosts do not have such includes)

Any ideas what went wrong here? Well, at least I have a workaround now!

comment:16 Changed 2 years ago by paxperscientiam (Chris)

Hello @alphanull, I want to add that I see the same anomalous behavior.

My /opt/local/etc/apache2/httpd.conf has the directive Include /Users/<user>/server-config/httpd.conf

That include in turn has the directive Include /Users/<user>/server-config/httpd-vhosts.conf.

As in your experience, sudo port load apache2 fails to start httpd. However, when I comment out Include /Users/<user>/server-config/httpd.conf, sudo port load apache2 successfully starts httpd.

I did a quick test to see if this might have something to do with including configs outside of Server Root -- it may. I replaced Include /Users/<user>/server-config/httpd.conf with Include etc/apache2/test.conf and it worked, though I had to kill running httpd processes before sudo port load apache2 and sudo port unload apache2 would work again.

The test.conf file was owned by "root:staff" when I created it. I then changed it to "<user>:admin" and still the load/unload commands work.

It's looking like this bug(?) has to do with whether the includes are outside of the server root. Not sure if this is the case. Hope this helps us get closer to a solution!

comment:17 Changed 10 months ago by yugaego (YE)

I've got a similar case: httpd process is launched fine on sudo port load apache2, but doesn't start after reboot. No of the listed here, linked, or other numerous attempted workarounds fixed the issue.

This happens on Ventura 13.4, Server version: Apache/2.4.57 (Unix), Server built: Apr 6 2023 23:30:38.

Investigation showed only one particular point of interest so far: system/org.macports.apache2 isn't mentioned in launchd.log on startup at all, whilst other services get such notices:

(system) <Notice>: Bootstrap by smd[89] for /Library/LaunchDaemons/org.macports.mysql8-server.plist succeeded (0: )

Adding a custom plist that starts httpd directly, without daemondo, works fine:

  <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version='1.0'>
<dict>
<key>Label</key><string>local.org.macports.apache2</string>
<key>ProgramArguments</key>
<array>
        <string>/opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper</string>
        <string>start</string>
</array>
<key>RunAtLoad</key><true/>
</dict>
</plist>

Any idea what could be done to further troubleshoot the issue?

If the issue might be connected to daemondo, should I file a bug report some other place maybe?

comment:18 Changed 10 months ago by yugaego (YE)

Cc: yugaego added
Note: See TracTickets for help on using tickets.