Category Archives: apache

MaxClients exceeded error in apache

Ever see an error in your log files that says you have exceeded your Max Clients? This is a simple problem; the most common configuration of apache is 10. If you have enough traffic on your website this simple setting can put your out of business. To fix this just change the number. You can find your configuration file at /etc/httpd/conf/httpd.conf. I would recommend that you use a simple editor to touch this file, like VI. Be sure to understand the commands of VI before editing any files. You will have to be logged in as Root or Super User to access this file.

Here is a few tips for editing a file with vi, to make the change we where just talking about. Do this.

vi /etc/httpd/conf/httpd.conf

Now you can see the contents of the file, make sure that you do not get a read only message. If you do, nothing you change can be saved.

To search for the line you are trying to edit, type this.

/MaxClients

The / command will search for anything after the slash.

With the arrow keys on your keyboard go to the number in this case ten, move your cursor below the first number. In this case 1.

The “x” lower case, command will erase a character at a time. Once you have removed both characters you want to put in a new number.

To do this hit “i” lower case, this is the insert command. After you hit “i” type in your number, say 25. You must hit escape to stop inserting.

Now if all is clean you need to exit the program, to do this type in “:wq”, the w stands for write, the q stands for quit. Now you will have to restart apache for this to take affect. Depending on how Apache is configured there are many ways to do this. If you have PLESK installed I would restart apache with PLESK. Restarting anything at the command prompt should not be taken lightly.

Obviously remove the “ quotes surrounding each command

SEO related HTTP Response Codes

Here is the list of HTTP Response codes that I think are important for SEO’s to watch for.

1). 200 OK, this means everything is perfect! Your file was successfully transferred and all is good.

2). 301, if you have intended for your page to redirect to another file then you are in good shape. The 301 header is a redirect message telling the browser/crawler that the page has moved.

3). 302, this means that you have specified that you are temporarily moving your file from one place to another. Also known as the redirect of death, if you must redirect to a new location do NOT use a 302 it can commonly damage your rankings and cause you a lot of head ache. Never ever use this!

I keep hearing that the major search engines have fixed all of the bugs related to 302’s, don’t believe them. Make sure you are protecting yourself.

4). 304, this is the not modified response. If you have a static site and hardly ever update your pages, the web server will respond with a 304 the page has not changed. Your cache date within Google will not change if you see this. If you want to make sure your pages stay fresh put in a date somewhere in your static pages and change them once a day. This will ensure that your pages are fresh.

If you have a Linux hosting environment you can use the “touch command” to update your file. This only changes the last modified date of the file, not the content.

Example:
bash-3.00$ touch index.html

If you want to automate this, you can write a Shell script that can be added to a Cron Job on your server.

5). All 400 and 500 errors are bad news. Make sure you are looking for these in your log files.

If you want to examine your log files for spider errors try this. It will allow you to see problems on your site.

Go to your linux command prompt. Change directories to your log files and experiment with the following command.

“more access-log | grep Googlebot | grep 404” if there is too much information to look at adjust your command to create a file with this search. “more access-log | grep Googlebot | grep 404 > spider-404-output.txt” This will create a file called spider-404-output.txt, and can give you an in site to what the search engines are seeing. You can always replace the 404 with another error code, say for example 500, to see other errors.

Here is a list of all the bad errors to watch out for.

400 Bad Request – Usually a bad request from the client, or if the link to this page was fallowed it may have formed a bad URL.

401 Unauthorized – If you are using password protection, you might see this.

402 Payment Required – This is a custom code, not used very often

403 Forbidden – Rarely used, usually a 404 is used instead.

404 – Not Found, watch for this one, and make sure that all of your pages are there.

405 – Method Not Allowed – Usually invalid header information, this one is not very commonly found.

406 – Not Acceptable – Again this one is very rarely used, but could be a server miss-configuration.

407 – Proxy Authentication Required – This one might be found on an internal company server where the IT department wants to make sure they are not being overloaded. Or that they can track your usage.

408 – Request Timeout – Commonly a server configuration problem, check your memory allotments.

409 – Conflict – Rarely used, no simple answer for this error.

410 – Gone – Page is gone and no forwarding information is available, not used very often.

411 – Length Required – Server miss configuration, very rarely used today.

412 – Precondition Failed – This would come up for custom header requests, very rarely used.

413 – Request Entity Too Large – Server config problem, common with early versions of Apache

414 – Request URI is Too Long – URI prefix is too long and pointing back too-itself, I have never seen this one reported.

415 – Unsupported Media Type – Common for really old web servers, unlikely to ever appear.

416 – Request Range Not Satisfiable – Very rare, usually a config problem. I have only seen this on Netscape servers.

417 – Exception Failed – Usually an extra character that came across the header, sometimes a bad link or cookie. Or just poor config.

500 – Internal Server Error – Almost always a bad config in Apache.

501 – Not Implemented – I rarely see this error, sometimes in Tomcat

502 – Bad Gateway – Commonly a Proxy problem or some strange network config

503 – Service Unavailable – You might be running out of server resources, RAM, CPU etc. Try upping your available server sessions or increase your client limit.

504 – Gateway Timeout – DNS problems, network problems. Not usually a web server problem.

505 – HTTP Version Not Supported – Should be self explanatory but if you see this, could be bad code, server config problem or a bad browser.

.htaccess redirects

Another question I get constantly is. How I do I safely redirect pages on my server? With an apache web server this can be very simple.

First do you have an .htaccess file in the root of your web server?

Yes? Don’t read this next line

No? Don’t worry, just make your own.

The syntax is really quite simple

Default redirect command will use a 302 action. For example

Redirect /oldpage.html http://www.destination.com/newpage.html

If you wish to use a 301, the SAFEST redirect and will tell the search engines that you have moved the page permanently.

Redirect permanent /oldpage.html http://www.new.com/page.html

These types of redirects are done within the header of the html file. The header is the part of the page you do not see with view source. These are the commands that the browser and or search engine uses to display the page correctly. DO NOT EVER use a java script based redirect, or a META refresh redirect! These are commonly used as spam or cloaking methods.

You can identify a META refresh by this command in the HEAD part of an HTML document.

<meta http-equiv=”refresh” content=”2;url=http://www.mynewpage.com”>

Appropriate

The number in the content= area, is the amount of time for the refresh to happen.

I have seen dozens of variation of .js redirecting, you can always ask me if you need one identified.