Today I encounter a serious error in my production server running Debian 3.1 with Apache 1.3, PHP 4.3
Warning: Unknown(/web_sites/doc_root/public_html/index.php): failed to
create stream: Too many open files in Unknown on line 0
The reason is linux limit the max number of opening files to 1024, and my server is hosting more than 500 virtual hosting now, and each of them opened 2 logs. So in total when the hosting is over 512 domains, it’ll reach the limit.
Run this command to see the limit:
linuxvm1:~# ulimit -n
1024
The solution: (I know you like this)
open /usr/sbin/apachectl (or apache2ctl )
add a line to it: ulimit -n 65536
restart apache:
apachectl restart
The problem should been fixed.
If you execute /etc/init.d/apache to restart, it may not work because Debian 3.1 is not using apachectl in /etc/init.d/apache
I’m not sure how to add the ulimit to it yet.