Optimizing Apache
Apache can be tweaked by changing a few of its settings to make it work faster with respect to the capability your server possess.
Some of the values that can be tweaked in the ‘Global’ section of Apache configuration file (found at /usr/local/apache/conf/httpd.conf) are explained below:
Timeout
This directive sets the maximum amount of time the server will allow a connection to remain open. The default value of 1200 (20 minutes) is appropriate for most instances.
KeepAlive
With this directive set to on, the server will attempt to record the userid of each query to the server. Keep this directive set to off unless you are willing to devote a significant amount of network bandwidth to this function.
MaxSpareServers and MinSpareServers
Apache has several statements to configure the number of clients being handled and the number of child-processes it forks off to deal with those requests. If the machine running the Apache installation is not intended for anything but running Apache, it is generally a good idea to make these numbers as high as possible, but not so high that the machine starts paging memory out to its swap space.
MaxRequestsPerChild
The MaxRequestsPerChild directive sets the limit on the number of requests that an individual child process can handle during its lifetime. After MaxRequestsPerChild requests, the child process will die. If MaxRequestsPerChild is zero, the process will live until the server kills it (because it is no longer needed, which will depend on the value of MinSpareServers and the number of current requests) or until the server itself is stopped.
Hard Drives going bad, how to get SATA/ATA device information.
# hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 582 MB in 2.00 seconds = 290.60 MB/sec
Timing buffered disk reads: 96 MB in 3.05 seconds = 31.49 MB/sec
Harddrives come in three kinds: Sata, Ide, and Scsi. Many type of hardware error will how up under linux if you use the command “dmesg”. In fact, almost any type of hardware error or information will show up there.
If you think your drive may be sub par, or you want to test it, then hdparm is a good command.
[~]# hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 270 MB in 2.01 seconds = 134.60 MB/sec
Timing buffered disk reads: 80 MB in 3.07 seconds = 26.10 MB/sec
If the second measurement is under 40MB/sec then you shoud change the drive for your server.
Below is the measurement for a new server.
[~]# hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 12252 MB in 2.00 seconds = 6135.69 MB/sec
Timing buffered disk reads: 212 MB in 3.01 seconds = 70.51 MB/sec
Note: SMART allows you to have a good degree of prediction on when the drive will reach its end of life.
Disable Script Execution Using .htaccess
You can disable scripts being run in the directory of your choice by adding the following code to your .htaccess file in that directory
This would be particularly useful if you allow visitors to upload files to your server, but want to be sure that any potentially harmful files they upload are not allowed to execute.
AddHandler cgi-script .php .pl .jsp .asp .sh .cgi
Options -ExecCGI
You can replace the file types in the example with the file types you wish to disallow using .htaccess.
How to disable serversignature using .htaccess
To disable the server’s signature used to identify the server, use the following code in your .htaccess file:
VNC ( Virtual Network Computing )
Installing the required packages
Make sure to install a window manager in order to get a normal GUI desktop.
yum groupinstall “GNOME Desktop Environment”
to install the Gnome Desktop and requirements, for example.
The server package is called ‘vnc-server’. Run the command
VNC is used to display an X windows session running on another computer. Unlike a remote X connection, the xserver is running on the remote computer, not on your local workstation. Your workstation ( Linux or Windows ) is only displaying a copy of the display ( real or virtual ) that is running on the remote machine.
If the server is not installed, install it with the command:
The client program is ‘vnc’. You can use the command