Your open source for Development and Design

Apache MaxClients

Filed under: Apache — Adi @ 12:46 am June 26, 2011

Working with Ubuntu or any other Linux distribution you really do learn something new every day. Yesterday one of my servers looked like Apache had Crashed.

Symptoms:

  • Loading a web page wont return a 404 or 500 error just a blank page
  • Restarting Apache will help for a minute or two
  • It’s a reoccurring issue
  • Happens when you have large spikes in traffic

Like most things in Linux it’s an easy fix as long as you know where to look.

To double check this is the issue load up the Apache Log, in Ubuntu it’s /var/log/apache2/error.log

You should see something like :

[Sat Jun 25 14:14:17 2011] [error] server reached MaxClients setting, consider raising the MaxClients setting

To resolve this issue go to /etc/apache2/apache2.conf and change the MaxClients settings from to a higher number. By default it’s 10 and I would recommend changing it to about 30+ if it’s shutting down at 10 requests. You will also need to restart Apache after you change the setting.

More information from Apache on MaxClients

Re: [#MQV-17419-739] nothing works

X
Inbox
X
WizzVPS Support
Thank you for your email with subject nothing works. Your request has been as…
Jun 18 (8 days ago)
Victor Inceu, WizzVPS Support
Hello, I have checked your system status and sshd daemon appears to be runnin…
Jun 18 (8 days ago)
Adrian Mursec
Hi What does the repair mode actually do, I’m trying to reset the server to t…
Jun 18 (8 days ago)
Victor Inceu, WizzVPS Support
Hi Adrian, With regards to the ‘Repair’ mode, please note that this won’t rei…
Jun 18 (8 days ago)
Adrian Mursec
Hi My websites don’t seem to load some times, Apache2 is still running and it…
2:12 PM (17 hours ago)
Reply
|
Ioan Nistor, WizzVPS Support to me
show details 2:21 PM (17 hours ago)
Hi Adrian,Something has to do with the sites, the maxclients value is reached pretty fast:

[Sat Jun 25 14:10:40 2011] [notice] Digest: generating secret for digest authentication …
[Sat Jun 25 14:10:40 2011] [notice] Digest: done
[Sat Jun 25 14:10:40 2011] [notice] Apache/2.2.14 (Ubuntu) DAV/2 SVN/1.6.6 mod_fcgid/2.3.4 PHP/5.3.2-1ubuntu4.9 with Suhosin-Patch mod_ruby/1.2.6 Ruby/1.8.7(2010-01-10) mod_ssl/2.2.14 OpenSSL/0.9.8k configured — resuming normal operations
[Sat Jun 25 14:10:45 2011] [error] server reached MaxClients setting, consider raising the MaxClients setting
[Sat Jun 25 14:13:13 2011] [notice] caught SIGTERM, shutting down
[Sat Jun 25 14:14:12 2011] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Sat Jun 25 14:14:12 2011] [notice] Digest: generating secret for digest authentication …
[Sat Jun 25 14:14:12 2011] [notice] Digest: done
[Sat Jun 25 14:14:12 2011] [notice] Apache/2.2.14 (Ubuntu) DAV/2 SVN/1.6.6 mod_fcgid/2.3.4 PHP/5.3.2-1ubuntu4.9 with Suhosin-Patch mod_ruby/1.2.6 Ruby/1.8.7(2010-01-10) mod_ssl/2.2.14 OpenSSL/0.9.8k configured — resuming normal operations
[Sat Jun 25 14:14:17 2011] [error] server reached MaxClients setting, consider raising the MaxClients setting

Please try to review first the sites you are hosting or increase the value for maxclients in apache config.

Regards,

Ioan Nistor

- Show quoted text -
Technical Support Engineer
WizzVPS.comAny prices stated exclude VAT at 20% (where applicable to EEC customers) unless explicitly stated otherwise. E&OE.

Access this ticket online: https://help.wizzvps.com
Follow us on Twitter: http://twitter.com/WizzVPS

WizzVPS is a trading name of Layershift Limited

Layershift Limited | Delta House | Wavell Road | Manchester | M22 5QZ | UK
Layershift Limited is a company registered in England and Wales (6036217). EU VAT number: GB 903 0349 62

=================================================================================
This email is confidential. If you are not the intended recipient of this email, please notify Layershift Limited immediately. Any form of  reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, either in whole or in part, is strictly prohibited without permission from Layershift Limited.

Reply
Forward
Adrian Mursec
Wow thanks for that, i’ve upped it to 50 for now and will do some research fo…
2:43 PM (16 hours ago)
Reply
|
Ioan Nistor, WizzVPS Support to me
show details 2:45 PM (16 hours ago)
Apache logs under debian/ubuntu are in /var/log/apache2/ directory.

- Show quoted text -
Regards,Ioan Nistor
Technical Support Engineer
WizzVPS.com

Any prices stated exclude VAT at 20% (where applicable to EEC customers) unless explicitly stated otherwise. E&OE.

Access this ticket online: https://help.wizzvps.com
Follow us on Twitter: http://twitter.com/WizzVPS

WizzVPS is a trading name of Layershift Limited

Layershift Limited | Delta House | Wavell Road | Manchester | M22 5QZ | UK
Layershift Limited is a company registered in England and Wales (6036217). EU VAT number: GB 903 0349 62

=================================================================================
This email is confidential. If you are not the intended recipient of this email, please notify Layershift Limited immediately. Any form of  reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, either in whole or in part, is strictly prohibited without permission from Layershift Limited.

Reply
Forward

Tracking visitors with PHP and Predefined variables

Filed under: Apache,PHP — Tags: , , , — Adi @ 4:37 pm January 15, 2009

Although Google analytics can tell us a lot about who is visiting our websites it is still flawed in many ways. Google analytics is a powerful tool but if the user has disabled Javascript or you want to know live stats it can be pretty useless.

Developing our own can be much more versatile as we can gather information straight from the server using PHP’s Predefined variables.

You can add your own version of with a database and a few lines of PHP code.

$time = mktime();
if (isset($_SERVER['REQUEST_METHOD'])) {   // HTTP-method
   $method = $_SERVER['REQUEST_METHOD'];
} else {
   $method = "";
}
if (isset($_SERVER['REMOTE_ADDR'])) {      // IP-adress
   $ip_adress = $_SERVER['REMOTE_ADDR'];
} else {
   $ip_adress = "";
}
if (isset($_SERVER['HTTP_USER_AGENT'])) {  // Browser
   $browser = $_SERVER['HTTP_USER_AGENT'];
} else {
   $browser = "";
}
if (isset($_SERVER['PHP_SELF'])) {         // Current page
   $page = $_SERVER['PHP_SELF'];
} else {
   $page = "";
}
if (isset($_SERVER['HTTP_REFERER'])) {    // Previous page
   $referer = $_SERVER['HTTP_REFERER'];
} else {
   $referer = "";
}

$sql="INSERT INTO user_log (time, method, page, referer, adress, browser) // Insert into database as new row
					VALUES('$time','$method','$page','$referer','$ip_adress','$browser')";
mysql_query($sql);

SEO Apache Mod rewrite

Filed under: Apache — Tags: , , — Adi @ 3:03 pm January 12, 2009

I always tried to avoid using the .htaccess file as it either works really well or will take down the entire site. The code below will work on most sites using apache as long as they have modrewrite turned on and you edit the rules to suit your domain.
You may ready be using a .htaccess file on your server so double check as it may not show up on all FTP programs.

But why do you need to use one, well the short answer is you don’t but the long answer is it can help a lot to stop duplicate content being taken off search engines and in turn help improve your SEO.
For example how often do you see urls like www.bbc.com/index.html ?

The code below will redirect any variation on your homepage to just one. it will add the www. to the domain name and remove the index.html or index.php which ever you might be using.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^somedomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.somedomain.com/$1 [R=301,L]

RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html(.*)\ HTTP/ [NC]
RewriteRule .* http://www.somedomain.com/ [R=301,L]

Switch to our mobile site