linux apache server interview questions and answers for Linux Admin

linux apache server interview questions and answers
Interview questions and answers on Apache server

Here is a list of 30 important Apache web Server Interview Questions.

Q1. Briefly explain Apache Web Server?

Ans: Apache Web Server is one of the most secure, powerful and popular open source HTTP Servers. It can be used to host anything from personal web sites to corporate domains.


Q2. What's the command to stop Apache?
Ans: kill the specific process that httpd is running under, or killall httpd. If you have apachectl installed, use apachectl stop.
Q3. What is location of log files for Apache server ?
Ans:  /var/log/httpd

Q4. How do you set up a virtual host in Apache?
<VirtualHost www.linuxelearn.in>
ServerAdmin admin@amitmaheshwari.in
DocumentRoot /home/apache/share/htdocs/hostedsites
ServerName www.linuxelearn.in
ErrorLog /home/apache/logs/error/hostedsites/error_log
TransferLog /home/apache/logs/access/hostedsites/access_log
</VirtualHost>

Q5. What is virtual hosting?

Ans:  Virtual hosting is a method for hosting multiple domain names on a server using a single IP address. Virtual hosting allows one server to share its resources, such as memory and processor cycles, in order to use its resources more efficiently.

Q6. What are the types of virtual hosts ?

Ans: name-based and IP-based.
Name-based virtual host means that multiple names are running on each IP address.
IP-based virtual host means that a different IP address exists for each website served. Most configurations are named-based because it only requires one IP address.

 Q7. How to restart Apache web server ?

Ans: service httpd restart
/etc/init.d/httpd  restart

Q8. How to check the version of Apache server ?

Ans: rpm -qa |grep httpd

Q9. What is mod_vhost_alias?

Ans: It allows hosting multiple sites on the same server via simpler configurations.

Q10. What does htpasswd do?

Ans: It creates a new user in a specified group, and asks to specify a password for that user.

Q11. What is meaning of "Listen" in httpd.conf file ?

Ans: Port number on which to listen for nonsecure (http) transfers.
Default port number of httpd is 80

Q12. On which port Apache server works ?
Ans: http - port 80
         https - port 443

Q13. Tell me name of main configuration file of Apache server ?

Ans: /etc/httpd/conf/httpd.conf

Q14.  If you specify both deny from all and allow from all, what will be the default action of Apache?

Ans: In case of ambiguity deny always takes precedence over allow.

Q15. Can I serve content out of a directory other than the DocumentRootdirectory?

Ans: Yes, by using “Alias” we can do this.

Q16. How do you change the default web root?

Ans: The solution is to change the DocumentRoot in httpd.conf file.

Q17. Site is accessible under many different hostnames; how to redirect clients so that they see only a single name?

Ans: 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:

NameVirtualHost *
<VirtualHost *>
ServerName www.example.net
ServerAlias example.com
Redirect permanent / http://www.example.com/
</VirtualHost>
<VirtualHost *>
ServerName www.example.com
DocumentRoot /usr/local/apache/htdocs
</VirtualHost>

Q18. On which version of apache you have worked ?
Ans: httpd-2.2.3

Q19. What do you mean by a valid ServerName directive?

Ans: The DNS system is used to associate IP addresses with domain names. The value of ServerName is returned whenthe server generates a URL. If you are using a certain domain name, you must make sure that it is included in your DNSsystem and will be available to clients visiting your site.

Q20. What is the main difference between <Location> and <Directory> sections?

Ans: Directory sections refer to file system objects; Location sections refer to elements in the address bar of the Web page

Q21. How do I turn automatic directory listings on or off in Apache?

Ans: 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:

<Directory /path/to/directory>
Options +Indexes
</Directory>
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:
<Directory /path/to/directory>
Options -Indexes
</Directory>

Q22. How to do URL Rewriting using Apache?

Ans: 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.

Q23. How do you set up Apache to require a username and password to access certain documents?

Ans: By using htpasswd program we can apply authentication to certain documents.

Q24. How  to enable PHP scripts on your server?

Ans:  If you have mod_php installed, use AddHandler to map .php and .phtml files to the PHP handler. AddHandler application/x-httpd-php .phtml .php

Q25. Which tool you have used for Apache benchmarking?

Ans: ab (Apache bench)
ab -n 1000 -c 10 http://www.test.com/test.html

Q26. Can we cache files which are viewed frequently?

Ans: Yes we can do it by using mod_file_cache module.
CacheFile /www/htdocs/index.html

Q27. How do you check for the httpd.conf consistency and any errors in it?
Ans: httpd –t

Q28. Apache runs as which user? and location of main config file?.

Ans: Apache runs with the user “nobody” and httpd daemon. Apache main configuration file: /etc/httpd/conf/httpd.conf (CentOS/RHEL/Fedora) and /etc/apache2.conf (Ubuntu/Debian).

Q29. On which port Apache listens http and https both?

Ans: By default Apache runs on http port 80 and https port 443 (for SSL certificate). You can also use netstat command to check ports.

Q30. What is DocumentRoot ?

Ans:  It is a location of files which are accessible by clients. By default, the Apache HTTP server in RedHat Enterprise Linux is configured to serve files from the /var/www/html/ directory.
  


.....Best Of Luck.....





Post a Comment