Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

The server is running fine -- or at least it seems to -- but there's always the following error:

apache2/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)

It happens with Apache 2.2.22-9 on Debian Wheezy.

# apache2ctl configtest

/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
Syntax OK

# service apache2 reload

[....] Reloading web server config: apache2/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
. ok

# service apache2 restart

[....] Restarting web server: apache2/usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
... waiting /usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted)
. ok

# service apache2 status

Apache2 is running (pid 32045).

share|improve this question
1  
Have a look at what you have in /etc/security/limits.conf and /etc/security/limits.d. It seems that you have APACHE_ULIMIT_MAX_FILES (see it in /usr/sbin/apache2ctl) variable set to something larger than the limit in that files. –  HUB Aug 6 '12 at 9:44

2 Answers 2

The problem stems from /usr/sbin/apache2ctl (on Debian). Check it out:

~$ grep ULIMIT /usr/sbin/apache2ctl
ULIMIT_MAX_FILES="${APACHE_ULIMIT_MAX_FILES:-ulimit -n 8192}"
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
    $ULIMIT_MAX_FILES

Here it is setting the number of open files allowed to 8192. Or trying to and failing, in your case.

So to avoid getting an error when apache2ctl does that, adjust your system's settings in the /etc/security/limits.conf file by adding these two lines:

*               soft    nofile          8192
*               hard    nofile          8192

I didn't increase it to more than necessary (8192) because I don't know what else it will impact. However this gets rid of the warning.

Not sure if you will need to reboot your system after that, because there is a dynamic element to the ulimits which I am not familiar with. However you can test easily enough to find out what your current ulimit num of files is:

ulimit -n

You might want to read where I found it: stackoverflow - setting ulimit

share|improve this answer

This might help:- http://ubuntuforums.org/showthread.php?p=11950245#post11950245

BTW,

sudo service apache2 restart # no errors
service apache2 restart      # errors
share|improve this answer
    
Thanks, I already saw that but it doesn't help. Using sudo or not doesn't change anything, I have the same error. –  Pascal Polleunus Aug 26 '12 at 15:00
1  
Worked for me! Totally forgot sudo. –  ThomasReggi Nov 15 '12 at 16:19
2  
+1 magic sudo always does the trick –  bicycle Sep 11 '13 at 0:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.