Archive for the tag 'Apache'

How to Run Apache and lighthttpd on port 80

We need to have 2 IP in the server then only we can run both apache and lighthttpd on the same port. Assume that you have already installed both apache and lighthttpd in the server.

Lighthttpd will help to increase the speed with a small memory consumption.

Go to apache configuration and locate Listen directive.

Here, Add “Listen” directive to all IP addresses of the server, except the IP for lighthttpd.

Listen IP_ADDRESS:80

Now, restart apache and then lighthttpd.

How to do this in WHM/cPanel.

Instead of modifying the file manually you need to exclude the IP address for lighttpd at

Main >> Service Configuration >> Apache Configuration >> Reserved IPs Editor

Reserved IPs Editor: By default, Apache is configured to listen on all available IPs. Apache can be configured to only respond on specific IPs. This editor provides an interface to specify the Apache IP restrictions. To reserve new IPs not found in this list, please add the IP to the server first.
You can try to access IP in browser and make sure both are listening on port 80.

Building the Apache Configuration File in WHM

The build process begins by distilling and recording Apache’s current configuration. The build time options you configured during the EasyApache setup are used to begin building the configuration.

Option modules such as mod_security are installed, and their corresponding modifications are made to the new Apache configuration file.
A new, assumedly valid Apache configuration file will exist in the configuration directory.
Directives added to the final Apache configuration file as defaults have been removed at this point.
No VirtualHost entries exist in the configuration file at this point.

The new configuration is distilled in much the same way as before; however, this time the configuration is used as the basis for creating the server’s main Apache configuration template.
New directives and values are stored.

Any directives and values held over from the previous configuration will retain their values from that configuration.
The combination of the main template and data stores will be the basis for regenerating the final configuration file.

Finally, the new Apache configuration file is generated from the template and data stores and checked for syntactical correctness.
If the new file passes the test, the process is complete.
If the file fails the syntax check, the previous Apache configuration is restored.

Reference: http://cpanel.net

Apache Security: Hide Apache Web Server Version number

Apache Web Server Version number with ServerSignature and ServerTokens directives

Open your httpd.conf file using text editor such as vi:

vi httpd.conf

There are two config directives that controls Apache version. The ServerSignature directive adds a line containing the Apache HTTP Server server version and the ServerName to any server-generated documents, such as error messages sent back to clients. ServerSignature is set to on by default. The ServerTokens directive controls whether Server response header field which is sent back to clients includes a description of the generic OS-type of the server as well as information about compiled-in modules.

Append/modify config directive as follows:

ServerSignature Off
ServerTokens Prod

Save and close the file. Restart Apache web server:

/etc/init.d/httpd restart
SBDavid

Auditing cPanle/WHM Apache logs

Auditing cPanle/WHM Apache logs

/usr/local/apache/logs/error_log

All exceptions caught by httpd, along with standard error output from CGI applications are logged here. The first place you should look when httpd crashes, or you incur errors when accessing a website.

/usr/local/apache/logs/suexec_log

This log file contains auditing information reported by suexec each time a CGI application is executed. If you receive an internal server error, with no relevant information being reported to the Apache error_log, check here for potential suexec policy violations.

How to check domain access logs

/usr/local/apache/domlogs/domain.com

The general access log for each domain configured with cPanel.

SBDavid

Apache configuration

Apache configuration on Ubuntu

Apache Default Timeout

Timeout 300

Timeout: The number of seconds before receives and sends time out.

This sets (in simple terms) the maximum time, in seconds, to wait for a request, action it and the response to the request.
The default is deliberately set high to allow for varied situations. You can reduce this to something more sane, to 30 seconds or even lower. A decrease may also help in reducing the effects of a DOS attack.
KeepAlive: Whether or not to allow persistent connections (more than one request per connection).

KeepAlive On

You should generally have KeepAlive “On” as it allows for persistent connections to a client so each file, image, etc. that gets requested. Without keepalives, the apache server and web client will need to establish new connections for every element needed to display a web page. Keeping a single connection going that the client can reuse allows your server to manage clients more efficiently.

MaxKeepAliveRequests

MaxKeepAliveRequests: The maximum number of requests to allow during a persistent connection. Set to 0 to allow an unlimited amount. We recommend you leave this number high, for maximum performance.

MaxKeepAliveRequests 100

Since we have our persistent connection, set the maximum number of requests per connection. Keep this high for maximum performance. You might want to experiment with this setting a bit, but if you have a site with lots of images, javascript, etc, try increasing MaxKeepAliveRequests to as much as 500.

« Prev - Next »