HPLogsdon

Information contained within is probably wrong

Mac OS 10.6.5 - /usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument

It's been a while since I've posted anything. Been a busy year so far. So busy, that I haven't hacked at my apache configuration in a while, and have been focusing on frontends of applications and stayed away from the backends. Up until today. I ran into an issue that required me to reload my php.ini, by restarting apache. No big deal, except for this little error:

/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument

What the hell? A little digging around and I see that Mac OS 10.6.5 updated the included Apache package, including some bug fixes. Apparently they left out a change that would have prevented this error. Luckily it is a quick fix, make a backup copy, and then open up /usr/sbin/apachectl in your favorite editor with root permissions and search for "ULIMIT_MAX_FILES":

sudo cp /usr/sbin/apachectl /usr/sbin/apachectl.BAK
sudo vim /usr/sbin/apachectl

And then remove everything in the quotes, as shown in this diff:

diff -rupN a/apachectl b/apachectl
--- a/apachectl    2011-01-23 21:03:49.000000000 -0700
+++ b/apachectl    2011-01-23 21:04:08.000000000 -0700
@@ -61,7 +61,7 @@ STATUSURL="http://localhost:80/server-st
 # number of file descriptors allowed per child process. This is
 # critical for configurations that use many file descriptors,
 # such as mass vhosting, or a multithreaded server.
-ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
+ULIMIT_MAX_FILES=""
 # --------------------                              --------------------
 # ||||||||||||||||||||   END CONFIGURATION SECTION  ||||||||||||||||||||

Then you're good to go. If you are uncomfortable editing system commands in an editor, feel free to save that diff to your home directory as a file called apachectl.patch, or similar and run it with:

patch -p1 < ~/apachectl.patch

That should take care of everything. For more information on diff files and patching, query:

man patch
man diff

or check out this article The Ten Minute Guide to diff and patch which I'll admit to referring to every once in a while when I need to create a patch by hand.