Tuesday, January 10, 2017

12 Essential Apache Web Server Interview Questions Answers - Java & Linux

The Apache HTTP Server, also known as httpd, has been the most popular web server on the Internet since April of 1996. It is both free and robust and that's the reason that almost half of the world's websites  runs on Apache HTTP web server, ranging from small hobby websites to huge e-commerce giants and big banks. There are also many companies which use Apache and Tomcat to host Java web application. In a typical setup, Apache web server receives the HTTP request and depending upon the URL it either route to Tomcat or serve the static files directly from the file system. These questions are based mostly on that experience. Though Apache is not just famous in Java world it is even more popular with other web technologies e.g. Perl, PHP, and MySQL. It's one of the powerful and secure web servers so anyone can use it to handle HTTP traffic. It supports both HTTP and HTTPS. It's worth noting that Apache is also an HTTP/1.1 compliant web server.

My collection contains 12 Apache httpd web server interview questions from Java and web interviews. The questions are focused on practical knowledge of working with apache server running on Linux environment. Since many banks and big companies use Apache httpd server together with Tomcat so that they can serve static resource using Apache and dynamic resource using Tomcat, these questions also check your understanding of how Apache httpd web server and Tomcat work together in Linux.




Top 12 Apache Web Server Interview Questions

Here is my list of Apache web server interview questions. The list is by no means complete or exhaustive, it just contains some essential questions to verify if a candidate has actually worked in Apache web server and Tomcat or not. I intend to keep this list up-to-date and add few more questions whenever I find from my talk with friends and colleagues interviewing. You can also help to share Apache and Tomcat related questions you have faced before on Java or Web development interviews.

1) What is Apache Web Server?
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 websites to corporate domains. The Apache HTTP Server, also known as "httpd" (HTTP daemon) was launched in 1995 and it has been the most popular web server on the Internet since April 1996. The latest version of Apache Web server is Apache httpd 2.4.23 which was released on 2016-07-05.



2) Does Apache support HTTP-only or it also support HTTPS?
Apache supports both HTTP and HTTPS protocol. It is HTTP/1.1 specification compliant web server


3) How do you find the port on which Apache Web Server is listening?
You can check the httpd.conf file for the keyword "Listen", that defines the port on which Apache listen. Alternatively, you can use netstat command in Linux to find the port on which Apache web server is listening as shown below:

$ netstat -nap | grep httpd
tcp 0 0 0.0.0.0:10202 0.0.0.0:* LISTEN 3988/httpd



4) How do you find which request are forwarded to tomcat?
You can check the mod_jk.conf and workers.properties file to find out about load balancer and the port on which they are listening. So, suppose Tomcat is listening on port 23454 then request coming on that port to Apache will be forwarded to the Tomcat.

Apache Web Server Interview Questions Answers


5) How do you start and stop Apache Web Server in Linux?
You can use following commands to start and stop the Apache web server in Linux

$ cd bin -- where bin is apache bin directory
$ ./apache.sh stop
$ ./apache.sh start


6) How do you find which version of Apache Web Server you are using?
Just run the following command in bin directory of Apache web server, it will display the version

$ ./apache.sh version


7) What is the difference between a restart and a graceful restart of a web server?
Answer: During a normal restart, the server is stopped and then started, causing some requests to be lost. A graceful restart allows Apache children to continue to serve their current requests until they can be replaced with children running the new configuration. See Pro Apache (Expert's Voice) learn more about fundamentals of Apache HTTP server.

12 Essential Apache Web Server Interview Questions Answers - Java & Linux


8) What is the main difference between and sections?
Answer: The Directory sections refer to file system objects; Location sections refer to elements in the address bar of the web page

9) What is DocumentRoot?
Answer: 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.


10) How to restart Apache web server?
Answer: service httpd restart or  /etc/init.d/httpd restart. You can also refer Apache CookBook to learn more about day-to-day stuff of Apache web server e.g. tuning logging or adding some common modules.


11) What are some important configuration files of Apache HTTP Server?
The httpd.conf is the main config file for Apache web server. If your Apache is communicating to Tomcat then you can also see mod_jk.conf,  workers.properties and alias.properties in conf folder.


12) Which configuration files you will look to understand how Apache communicates to Tomcat?
The mod_jk.conf and the workers.properties file is used to specify tomcat related config e.g. which URL should be routed to tomcat, which port to listen etc


That's all about some basic Apache Web Server Interview Questions and Answers. These questions will help you to understand Apache HTTP server more in little more detail and give you some idea of what you can expect in Java and Web development interview which require developing enterprise web application using Java technologies e.g. Servlet, JSP, JSF, Spring, or JEE etc.

Btw, Apache is used not just in Java space but anywhere where a web server is required to serve HTML files or other static resources. You can found Apache with.NET projects or even PHP projects, even most of the internet sites are built using Apache, PHP, MySQL and Linux. You can also read Pro Apache (Expert's Voice) or Apache: The Definitive Guide to learn more about Apache fundamentals, Security, SSL, Performance and error handling in Apache.


Some more interview questions articles for Java web developers
  • 10 Essential Spring Framework Interview Questions with Answers (see here)
  • 12 Essential RESTful Web Services Questions from Interviews (read here)
  • 10 Essential Hibernate Interview Questions for Java EE developers (see here)
  • 10 Essential XML Interview Questions for Java Programmers (read here)
  • 20 Essential Java Design Pattern Questions asked on Interviews (see here)
  • 10 popular Struts Interview Questions for Java developers (list)
  • 10 Frequently asked Servlet Interview Questions with Answers (see here)
  • 20 jQuery Interview Questions for Java Web Developers (list)
  • Top 10 JSP Questions  from J2EE Interviews (read here)
  • Top 10 EJB Interview Questions and Answers (see here)
  • Top 10 JMS and MQ Series Interview Questions and Answers (list)
  • 10 Essential JDBC Interview Questions for Java Programmers (questions)
  • Top 10 XSLT Interview Questions with Answers (read more)

References
http://httpd.apache.org/docs/
http://httpd.apache.org/docs-project/

2 comments :

Anonymous said...

Thanx for article. There is some typo in 8th point.

Anonymous said...

Very interesting and helpful. Thanks.

Post a Comment