Leopard Apache won’t start after reboot

I took the following from this google posting: http://old.nabble.com/-JIRA–Issue-Comment-Edited:-(MAGNOLIA-1959)-Leopard-(osx-10.5)-issues-td21853819.html

Just following up my previous posts and the solution we found to work with the ‘Too Many Open Files’ error, maybe it will help others as well.

The problem seems to be in the way Apple has changed the files/proc settings for Leopard. Using the ‘ulimit’ and ‘sysctl’ options to adjust the settings no longer works.

The option you have to use is the ‘launchctl limit’ command, which also adjusts both the ‘ulimit’ and the ‘sysctl’ settings automatically.

To check your existing settings, you can use the command ‘launchctl limit’, this shows that the server is ridiculously set at a very low maxfiles of 256 files per user/process.

Three columns will be returned, the first column displayed will be the name of the limit setting, you are looking for the ‘maxproc’ and/or ‘maxfiles‘ settings towards the bottom of the list.

To increase the maxfiles you can use the command ‘launchctl limit maxfiles user max system max’, where user max is the maximum files you want to allow for each user/process and likewise for system max.

An example would be (running as super user): launchctl limit maxfiles 2048 unlimited

We first increased this to 2048 unlimited as Apple states in the manual that the Server Admin app is supposed to change the soft process limit from 100 (the default) to 2048 when starting Apache, obviously this is not happening and the default is set to 256, so the manual is out of date or wrong. We did however still find infrequent ‘too many open files’ errors in apache logs so again increased the limit, this time to 4096 unlimited and have not had a problem since.

The same applies to the maxproc setting if you need additional processes.

You can verify the changes by using the ‘ulimit -a’ and/or ‘sysctl -a | grep files’ commands.

To make the changes stick through a restart, you need to add a file (as it doesn’t exist) by using something like ‘sudo pico /etc/launchd.conf’ and add the changes one per line, so in our case, our file looks like this:

limit maxfiles 4096 unlimited

Remember you do not need to add ‘launchctl’ in front of the commands in this file.

Hope this helps others with this problem, we have not upgraded to 10.5.3 yet, now that things are working in 10.5.2 we will have to setup a test environment before applying anymore potential fuel to the fire!

So I increased the maxfiles to 4096 (launchctl limit maxfiles 4096 unlimited) and the maxproc to 2048 (launchctl limit maxproc 2048 unlimited).

After this two instances are starting fine.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s