Apache 2 - am I doing it wrong?

Bradley Giesbrecht brad at pixilla.com
Thu Sep 10 12:28:37 PDT 2009


On Sep 10, 2009, at 2:46 PM, Scott Haneda wrote:

> On Sep 10, 2009, at 10:31 AM, Bradley Giesbrecht wrote:
>
>> On Sep 10, 2009, at 1:28 PM, Scott Haneda wrote:
>>
>>> I have apache 2 via MacPorts running.
>>>
>>> First issue, reloading I use apachectl. Often times I forget to cd  
>>> to the macports area and enable Apples distro. Is chmod -x  
>>> apachectl sufficient to solve that?
>>>
>>> I can move, rename, symblink, or alias, but wanted opinions on the  
>>> suggested way.
>>>
>>> After a apachectl graceful, which I'm doing often as I secure and  
>>> tune phi.ini, looking at output from ps I see all httpd processes.  
>>> Each has the graceful command in the ps output
>>>
>>> There are usually 10-15 threads running like this. I am used to  
>>> just seeing httpd listed, sans the graceful line.
>>>
>>> Is apachectl the incorrect way to start, stop, or allow a friendly  
>>> reload where connections can finish?
>>>
>>> I've seen another command used to starts and stop, httpd I  
>>> believe, is that the preferred method? What's the difference?
>>
>> I can't answer your questions but I like to just write shell  
>> scripts that load, unload and reload services or combinations of  
>> services using launchctl.
>
>
> What do you get for: `ps aux | grep http`
> I have about 10 lines of
> _www     74642   0.0  0.1    94448   4636   ??  S    Sun05PM    
> 0:00.39 /opt/local/apache2/bin/httpd -k graceful
>
> I actually have a hack of a time stopping apache.  Is the idea to  
> start and stop it via launchctl?  Or is trying to start and stop it  
> via apachectl or httpd -k stop just mean that launchd is going to  
> kick it in start again?
>
> I had to unload the plist, kilall httpd, and then finally got a  
> clean ps output.
>
> What does your apache shell script look like that starts, stops, and  
> reloads?

If you have launchd monitoring a service that launchd is supposed to  
launch if it crashes I'm afraid all your apachectl type apps that kill  
and then start services will not work well. Launchd will see the  
service go away and fire it back up and apachectl type apps will also  
be starting the service. Things like postfix/postconf that can alter a  
configuration without bouncing the process shouldn't have this problem.

So I just write very simple scripts like:

loadapache.sh
#!/bin/bash
launchctl load -w /Library/LaunchDaemons/org.macports.apache.plist

unloadapache.sh
#!/bin/bash
launchctl unload -w /Library/LaunchDaemons/org.macports.apache.plist

reloadapache.sh
#!/bin/bash
unloadapache.sh
sleep 5
loadapache.sh


// Brad


More information about the macports-users mailing list