Jul
20
2007
0

Too many open files

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.

Written by hkai in: Apache, Linux General, PHP |
Jun
30
2007
0

Setting up SSL for apache2 on Debian 4.0

  1. cd /etc/apache2/
  2. mkdir ssl
  3. cd ssl
  4. openssl genrsa -out server.key 1024
  5. openssl req -new -key server.key -out server.csr
        • type in the information required in this step
      1. openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
      2. cd /etc/apache2
      3. vi ports.conf
            • add Listen 443 into the file and save
          1. cd /etc/apache2/sites-available
          2. vi ssl, add the following
          3. a2enmod ssl
          4. a2ensite ssl
          5. /etc/init.d/apache2 restart
          6. open https://localhost in your browser and accept the key
          7. the browser should say: It works!

          NameVirtualHost *:443
          <VirtualHost *:443>
          ServerAdmin webmaster@localhost
          SSLEngine on
          SSLCertificateFile /etc/apache2/ssl/server.crt
          SSLCertificateKeyFile /etc/apache2/ssl/server.key
          DocumentRoot /var/www/
          <Directory />
          Options FollowSymLinks
          AllowOverride None
          </Directory>
          <Directory /var/www/>
          Options Indexes FollowSymLinks MultiViews
          AllowOverride None
          Order allow,deny
          allow from all
          # This directive allows us to have apache2’s default start page
          # in /apache2-default/, but still have / go to the right place
          RedirectMatch ^/$ /apache2-default/
          </Directory>

          ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
          <Directory “/usr/lib/cgi-bin”>
          AllowOverride None
          Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
          Order allow,deny
          Allow from all
          </Directory>

          ErrorLog /var/log/apache2/error.log

          # Possible values include: debug, info, notice, warn, error, crit,
          # alert, emerg.
          LogLevel warn

          CustomLog /var/log/apache2/access.log combined
          ServerSignature On
          </VirtualHost>

          Written by hkai in: Apache, Linux Debian |

          Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes