Apache Interview Questions
Here is a list of 10 important Apache Interview Questions.
kill the specific process that httpd is running under, or killall httpd. If you have apachectl installed, use apachectl stop.
2) How do you set up a virtual host in Apache?
3) What is mod_vhost_alias?
It allows hosting multiple sites on the same server via simpler configurations.
4) What does htpasswd do?
It creates a new user in a specified group, and asks to specify a password for that user.
5) If you specify both deny from all and allow from all, what will be the default action of Apache?
In case of ambiguity deny always takes precedence over allow.
6) How do you change the default web root?
The solution is to change the DocumentRoot in httpd.conf file.
7) Site is accessible under many different hostnames; how to redirect clients so that they see only a single name?
Many sites map a variety of hostnames to the same content. For example, www.example.com, example.com and www.example.net may all refer to the same site. It is best to make sure that, regardless of the name clients use to access the site, they will be redirected to a single, canonical hostname.
This makes the site easier to maintain and assures that there will be only one version of the site in proxy caches and search engines.
There are two techniques to implement canonical hostnames:
1. Use mod_rewrite as described in the "Canonical Hostnames" section of the URL Rewriting Guide.
2. Use name-based virtual hosting:
Redirect permanent / http://www.example.com/
8) How do I turn automatic directory listings on or off in Apache?
If a client requests a URL that designates a directory and the directory does not contain a filename that matches the
DirectoryIndex directive, then mod_autoindex can be configured to present a listing of the directory contents.
To turn on automatic directory indexing, find the Options directive that applies to the directory and add the Indexes
keyword. For example:
To turn off automatic directory indexing, remove the Indexes keyword from the appropriate Options line. To turn off
directory listing for a particular subdirectory, you can use Options -Indexes. For example:
9) How to do URL Rewriting using Apache?
By using Apache module mod_rewrite we can do url rewriting. It is a really sophisticated module which provides a
powerful way to do URL manipulations.
10) How do you set up Apache to require a username and password to access certain documents?
By using htpasswd program we can apply authentication to certain documents.