Apachectl Ulimit Error

by Simon. Average Reading Time: less than a minute.

Restarting Apache on my MacBook Pro today, using the command line argument sudo apachectl -k start resulted in a rather strange error:

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

After a little investigating it turned out to be caused by an update in the apachectl script to OSX 10.6.5.

The ULIMIT_MAX_FILES variable increases the maximum 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.

A quick edit of the the apachectl script and it’ll be back working.

I use TextMate, so the command is:

sudo mate /usr/sbin/apachectl

You’ll be prompted for your password.

Once the apachectl file is open, look for the following line (for me it was line 64):

ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"

and replace with the following:

ULIMIT_MAX_FILES="ulimit -S -n"

This will set the correct command that increases the maximum number of file descriptors allowed per child process.

This article has been tagged

, , , , ,

Other articles I recommend

Setting up PHP on Mac OSX 10.6 (Snow Leopard)

Since Apple launched Mac OS X 10.5 (Leopard), PHP has been installed by default, albeit disabled. Here is a quick run through of what you need to do to get it up and running.

Using Ant with Eclipse

If you’re currently not using Eclipse as your development tool of choice, you certainly should be! Eclipse is an open source community whose projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle.

Installing Apache on Vista

Following the purchase of a spangly new Toshiba laptop running Vista, and not one for making life simple, I decided not to run my development environment on IIS7, but rather, I wanted to install the latest version of Apache. The installation process was not a trivial matter!