Friday, December 2, 2011

Apache Questions

Q1 How to enable Directory Listing

Ans Place "Options +Indexes" in Directory Tabs

Q2 Allow Apache to use / access symbolic links directory/files

Ans Place "Options +FollowSymLinks" in Directory Tabs

Q3 Allow Apache to use / access .htaccess file

Ans Place "AllowOverride All" in Directory Tabs

Q4 Can we replace .htaccess file to some other for our convenient

Ans Yes, change "AccessFileName .htaccess" to "AccessFileName .xyz"

Q5 Set default number of start processes

Ans Find "StartServers ..." and set as per your requirement

Q6 How to disable Apache signature/version

Ans ServerSignature Off

Q7 How to block/disable TRACE

Ans Use "TraceEnable Off" globally so that TRACE will be disabled for all VHOSTS

Q8 Best tools for monitoring Apache Requests

Ans use Apache Handler "server-status" and APACHETOP tool (its like TOP command in linux)

Q9 How can we protect our site to avoid DOS/DDOS attacks

Ans Use mod_evasive apache module or this can also be done through firewall

Q10 Redirect to

Ans Use following in VHOST : - "Redirect /"

Q11 Which Apache processes are consuming higher memory

Ans Use ApacheTop or "ps -ylC httpd --sort rss" this command will show all apache processes in ascending order according to \memory size used by per process (RSS field)

Q12 What are different MPM's available in Apache for Linux and how they work

Ans There are 2 MPMs available 1) Worker 2) Prefork


        Worker :- This Multi-Processing Module (MPM) implements a hybrid multi-process multi-threaded server. By using threads to serve requests, it is able to serve a large number of requests with fewer system resources than a process-based server. However, it retains much of the stability of a process-based server by keeping multiple processes available, each with many threads.

The most important directives used to control this MPM are ThreadsPerChild, which controls the number of threads deployed by each child process and MaxClients, which controls the maximum total number of threads that may be launched

      Prefork :- This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries. It is also the best MPM for isolating each request, so that a problem with a single request will not affect any other.

This MPM is very self-regulating, so it is rarely necessary to adjust its configuration directives. Most important is that MaxClients be big enough to handle as many simultaneous requests as you expect to receive, but small enough to assure that there is enough physical RAM for all processes.

Q13 Write a Rewrite rule to redirect (www) to

Ans RewriteEngine On
       RewriteCond %{HTTP_HOST} ^$ [NC,OR]
       RewriteCond %{HTTP_HOST} ^$ [NC]
       RewriteRule ^/request.php$ [L]

Q14 How many connections apache server can handle

Ans This completely depends on our server configuration mainly on RAM

        Max no. of connections = (Total Memory - Memory Used By System For Its use) / average single apache process size*

        *Average Single Apache Process Size : Can be find using "top" command or "ps -ylC httpd --sort rss"

To be continued....

No comments: