Apache Interview Questions and Answers - Apache Web Server


In this section, I have selected Basic and Important Apache interview questions and answers for all levels of candidates(Fresher level, experienced level).Last few months I have been working to select best question and answer set for Apache  interview questions.

Apache Interview Questions and Answers:
------------------------------------------------------------------------------------------------------------

How do you set up a virtual host in Apache?

Ans: <VirtualHost www.test.com>
    ServerAdmin admin@test.com
    DocumentRoot /home/Public_html/site
    ServerName www.test.com
    ErrorLog /home/apache/logs/error/site/error_log
    TransferLog /home/apache/logs/access/site/access_log
</VirtualHost>
------------------------------------------------------------------------------------------------------------

htpasswd :
Ans: It creates a new user and asks to specify a password for that user.
------------------------------------------------------------------------------------------------------------

What's the command to stop Apache?
Ans:
apachectl -k stop
/etc/init.d/apache2 stop (Linux)
------------------------------------------------------------------------------------------------------------

What's the command to Restart Apache?
Ans:
apachectl -k restart
/etc/init.d/apache2 restart
------------------------------------------------------------------------------------------------------------

What's the location of log files for Apache server ?
Ans:  /var/log/httpd
------------------------------------------------------------------------------------------------------------

What's the Comamnd to check the version of Apache server ?
Ans: rpm -qa |grep httpd
------------------------------------------------------------------------------------------------------------

Apache server works on which ports ?
Ans: http – port 80
     https – port 443
------------------------------------------------------------------------------------------------------------

How t to enable PHP scripts on your server?
Ans: If you have mod_php installed, use AddHandler.
AddHandler application/x-httpd-php .phtml .php
------------------------------------------------------------------------------------------------------------

If you specify both deny from all and allow from all, what will be the default action of Apache?
Ans: Deny always takes precedence over allow.
------------------------------------------------------------------------------------------------------------

How do you change the default web root?
Ans: Change the DocumentRoot in httpd.conf file.
------------------------------------------------------------------------------------------------------------

How to enable htaccess on Apache?
Ans:
Open httpd.conf and remove the comment on line from

;LoadModule rewrite_module modules/mod_rewrite.so

Find the following
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

and change it to
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
------------------------------------------------------------------------------------------------------------

Does Apache act as Proxy server?
Ans: Yes,using mod_proxy module.
------------------------------------------------------------------------------------------------------------