25 Apache Interview Questions for Beginners and Intermediates
We are very thankful to All our readers for the response we are getting for our new Linux Interview section. And now we have started section wise learning for Interview questions and continuing with the same today’s article focuses on Basic to Intermediate Apache interview Questions that will help you to prepare yourself.
In this section, we have covered some interesting 25 Apache Job Interview Questions along with their answers so that you can easily understand some new things about Apache that you might never known before.
Before you read this article, We strongly recommend you to don’t try to memorize the answers, always first try to understand the scenarios on a practical basis.
1. What is Apache web server?
2. How to check Apache and it’s version?
[[email protected] ~]# rpm -qa | grep httpd httpd-devel-2.2.15-29.el6.centos.i686 httpd-2.2.15-29.el6.centos.i686 httpd-tools-2.2.15-29.el6.centos.i686
[[email protected] ~]# httpd -v Server version: Apache/2.2.15 (Unix) Server built: Aug 13 2013 17:27:11
3. Apache runs as which user? and location of main config file?.
4. On which port Apache listens http and https both?
[[email protected] ~]# netstat -antp | grep http tcp 0 0 :::80 :::* LISTEN 1076/httpd tcp 0 0 :::443 :::* LISTEN 1076/httpd
5. How do you install Apache Server on your Linux machine?
[[email protected] ~]# yum install httpd
[[email protected] ~]# apt-get install apache2
6. Where you can find all configuration directories of Apache Web Server?
[[email protected] ~]# cd /etc/httpd/ [[email protected] httpd]# ls -l total 8 drwxr-xr-x. 2 root root 4096 Dec 24 21:44 conf drwxr-xr-x. 2 root root 4096 Dec 25 02:09 conf.d lrwxrwxrwx 1 root root 19 Oct 13 19:06 logs -> ../../var/log/httpd lrwxrwxrwx 1 root root 27 Oct 13 19:06 modules -> ../../usr/lib/httpd/modules lrwxrwxrwx 1 root root 19 Oct 13 19:06 run -> ../../var/run/httpd
[[email protected] ~]# cd /etc/apache2 [[email protected] apache2]# ls -l total 84 -rw-r--r-- 1 root root 7113 Jul 24 16:15 apache2.conf drwxr-xr-x 2 root root 4096 Dec 16 11:48 conf-available drwxr-xr-x 2 root root 4096 Dec 16 11:45 conf.d drwxr-xr-x 2 root root 4096 Dec 16 11:48 conf-enabled -rw-r--r-- 1 root root 1782 Jul 21 02:14 envvars -rw-r--r-- 1 root root 31063 Jul 21 02:14 magic drwxr-xr-x 2 root root 12288 Dec 16 11:48 mods-available drwxr-xr-x 2 root root 4096 Dec 16 11:48 mods-enabled -rw-r--r-- 1 root root 315 Jul 21 02:14 ports.conf drwxr-xr-x 2 root root 4096 Dec 16 11:48 sites-available drwxr-xr-x 2 root root 4096 Dec 6 00:04 sites-enabled
7. Can Apache be secured with TCP wrappers?
8. How to change default Apache Port and How Listen Directive works in Apache?
Suppose you have multiple IPs assigned to your Linux machine and want Apache to receive HTTP requests on a special Ethernet port or Interface, even that can be done with Listen directive.
To change the Apache default port, please open your Apache main configuration file httpd.conf or apache2.conf file with VI editor.
[[email protected] ~]# vi /etc/httpd/conf/httpd.conf [[email protected] ~]# vi /etc/apache2/apache2.conf
Search for the word ”Listen”, comment the original line and write your own directive below that line.
# Listen 80 Listen 8080 OR Listen 172.16.16.1:8080
Save the file and restart the web server.
[[email protected] ~]# service httpd restart [[email protected] ~]# service apache2 restart
9. Can we have two Apache Web servers on a single machine?
10. What do you mean by DocumentRoot of Apache?
11. How to host files in different folder and what is Alias directive?
To use Alias directive, Its the part of mod_alias module of Apache. The default syntax of Alias directive is:
Alias /images /var/data/images/
Here in above example, /images url prefix to the /var/data/images prefix that mean clients will query for “http://www.example.com/images/sample-image.png” and Apache will pick up the “sample-image.png” file from /var/data/images/sample-image.png on the server. It’s also known as URL Mapping.
12. What do you understand by “DirectoryIndex”?
The default setting of DirectoryIndex is .html index.html index.php, if you have different names of your first file, you need to make the changes in httpd.conf or apache2.conf for DirectoryIndex value to display that to your client browser.
# # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # # The index.html.var file (a type-map) is used to deliver content- # negotiated documents. The MultiViews Option can be used for the # same purpose, but it is much slower. # DirectoryIndex index.html index.html.var index.cgi .exe
13. How to disable Directory listing when an index file is missing?
To stop Apache directory listing, you can set the following rule in the main configuration file globally or in .htaccess file for a particular website.
<Directory /var/www/html> Options -Indexes </Directory>
14. What are different log files of Apache Web Server?
15. What do you understand by “connection reset by peer” in error logs?
16. What is Virtual Host in Apache?
You are free to add as many directives you require for your domain, but the two minimal entries for a working website is the ServerName and DocumentRoot. We usually define our Virtual Host section at the bottom of httpd.conf file in Linux machines.
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /www/docs/dummy-host.example.com ServerName dummy-host.example.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common </VirtualHost>
- ServerAdmin : Its usually the email address of the website owner, where the error or notification can be sent.
- DocumentRoot : location where the web files are located in the server(Necessary).
- ServerName : Its the domain name which you want to access from your web browser(Necessary).
- ErrorLog : Its the location of the log file where all the domain related logs are being recorded.
17. What’s the difference between <Location> and <Directory>?
18. What is Apache Virtual Hosting?
For more information, read on How to Create Name/IP based Virtual Hosts in Apache.
19. What do you understand by MPM in Apache?
20. What is the difference between Worker and Prefork MPM?
- Basic difference between Worker and MPM is in their process of spawning the child process. In the Prefork MPM, a master httpd process is started and this master process starts manages all other child processes to serve client requests. Whereas, In the worker MPM one httpd process is active, and it uses different threads to serve client requests.
- Prefork MPM uses multiple child processes with one thread each, where worker MPM uses multiple child processes with many threads each.
- Connection handling in the Prefork MPM, each process handles one connection at a time, whereas in the Worker mpm each thread handles one connection at a time.
- Memory footprints Prefork MPM Large memory footprints, where Worker has smaller memory footprints.
21. What’s the use of “LimitRequestBody” and how to put limit on your uploads?
For example: I want to put limits of 100000 Bytes in the folder /var/www/html/tecmin/uploads. So, you need to add following directive in Apache configuration file.
<Directory "/var/www/html/tecmint/uploads"> LimitRequestBody 100000 </Directory>
22. What is mod_perl and mod _php?
23. What is Mod_evasive?
For more information, read the article that guides you how to install and configure mod_evasive in Apache.
24. What is Loglevel debug in httpd.conf file?
25. What’s the use of mod_ssl and how SSL works with Apache?
How SSL works with Apache
Whenever an https requests comes, these three steps Apache follows:
- Apache generates its private key and converts that private key to .CSR file (Certificate signing request).
- Then Apache sends the .csr file to the CA (Certificate Authority).
- CA will take the .csr file and convert it to .crt (certificate) and will send that .crt file back to Apache to secure and complete the https connection request.
These are just most popular 25 questions being asked these days by Interviewers, please provide some more interview questions which you have faced in your recent interview and help others via our Comment section below.
We are also recommend you to read our previous articles on Apache.
- 13 Apache Web Server Security and Hardening Tips
- How to Sync Two Apache Web Servers/Websites Using Rsync
Also, we are proud to announce that our Beta version of Question/Answer section of TecMint Ask is Already launched. If you have questions on any Linux topics. Please join us and post your questions/queries at https://www.tecmint.com/ask/.
I’ll come up with some more Interview question on DNS, Mail servers, PHP etc in our future articles, till then stay Geeky and connected to TecMint.com.