Archive for the tag 'Apache'

Configure Apache to listen multiple ports

The listen directive in the Apache configuration file can be used to make Apache to listen in a particular port or IP address or port combination.

Listen 80
Listen 8000

In this format the Apache server listens on the given ports on all interfaces (IP addresses) which are up in the server. If you mention the above two directives in the Apache configuration file then the Apache server will listen on both the ports 80 and 8000. Multiple Listen directives may be used to specify a number of addresses and ports to listen to.

Listen IP:80

You need to replace the IP address in this example with the IP address you want the Apache service to listen. In this format an IP address is given as well as a port. In this case the server will listen on the given port and interface( IP address ). If you want the Apache service to listen on two IP addresses in the server you can use multiple listen directive in the configuration file.

Listen IP1:80
Listen IP2:80

Please remember to restart the Apache service in the server once the changes are made to the configuration file.

SBDavid

Apache HTTP server benchmarking tool

Apache HTTP server benchmarking tool

ApacheBench is actully a command line program for measuring the performance of HTTP web servers. It was designed to give an idea of the performance that a given Apache installation can provide.

For bench marking the apache we can use the tool ab.

ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per sec-ond your Apache installation is capable of serving.

The syntax for using the tool is as follows.

$ ab -n 10 -c 2 http://www.your-domain-name.com/index.html

-n: specifies the number of request that is to be sent to the apache server for the bench marking session.
-c: specifies the number of multiple requests to perform at a time to the server.

Apache failed to start with the “No space left on device” error.

If you receive the following error while restarting Apache in the server, you need to do the following steps.

These errors means that there is no available IPC (inter-process communication) resources in the system, such as semaphores or shared memory segments. You need to check IPC resources which are used in the server using ‘ipcs’ command:

$ ipcs -a

—— Semaphore Arrays ——–
key semid owner perms nsems
0×00000000 201293824 apache 600 1

You will be able to see a lot of semaphores under Apache . You need to kill those processes using the following script and restart apache.

$ ipcs -s | grep apache | perl -e ‘while (<STDIN>) {@a=split(/\s+/); print `ipcrm sem $a[1]`}’

$ service httpd restart

Run Apache and lighttpd on same port 80

In a short description, lighttpd is a *ligthy* webserver which helps to increase the site load speed with a small memory consumption.
Now, I assume that you have already installed both apache and lighttpd in the server.

The main thing should be noted here is we need to have 2 IP’s in the server so that we can run both apache and lighttpd in the same port but on specific and dedicated IP addresses.

Go to apache configuration (CentOS/Fedora/RHEL: /etc/httpd/conf/httpd.conf) and locate the “Listen” directive.

Once you are there, you will probably see “Listen :80″ which tells apache to listen on ALL the interfaces. You will need to change this to make apache listen on just one of your IP addresses ie:

“Listen 12.12.12.1:80″

Pick one for apache and do the same for the lighttpd configuration(CentOS/Fedora/RHEL: /etc/lighttpd/lighttpd.conf) but in this case use the other free IP address.

Now, restart apache and then lighttpd. You can try to access IP in browser and make sure both are listening on port 80.

How to increase the MaxClients value greater than the current HARD_SERVER_LIMIT set for Apache.

1. Check if there is any hard server limit.

/usr/local/apache/bin/httpd -V | grep HARD_SERVER_LIMIT

2. Look for this directive in the Apache’s header file /usr/local/apache/include/httpd.h

3. Edit this file and increase the HARD_SERVER_LIMIT as per your requirement.

4. Recompile Apache using

/scripts/easyapache

5. There you will have an option to increase the Apache HARD_SERVER_LIMIT, since easyapache looks for the header files and sees the new value while build. By default the MaxClients value will be 256.
Once the build completes, you can see the new HARD_SERVER_LIMIT.

« Prev - Next »