Apache Tomcat Interview Questions And Answers

TOP 100 Apache Tomcat Interview Questions And Answers

Latest Apache Tomcat Interview Questions And Answers

Frequently asked Apache Tomcat Interview Questions And Answers are as follows-

  1. What is Tomcat?
    Answer:Tomcat is a Java Servlet container and web server from the Jakarta project of the Apache software foundation.
    A web server responds with web pages to requests from client browsers.
    Web servers can provide dynamic content based on the requests sent by the user.
    Tomcat is very good at this because it provides both Java servlet and JavaServerPages (JSP) technologies.
    Tomcat can also be used as a web server for many applications even if free servlet and JSP engine are wanted.
    It can be used standalone or used behind traditional web servers such as Apache httpd, with the traditional server serving static pages and Tomcat serving dynamic servlet and JSP requests.
  2. Difference between apache and apache-tomcat server?
    Answer:  Apache:
    Apache mostly serves static content by itself, but there are many add-on modules (some of which come with Apache itself) that let it modify the content and also serve dynamic content written in Perl, PHP, Python, Ruby, or other languages.
    Basically Apache is an HTTP Server, serving HTTP.
    Apache-Tomcat:
    Tomcat is primarily a servlet/JSP container. It’s written in Java. It can serve static content too, but its main purpose is to host servlets and JSPs.
    JSP files (which are similar to PHP, and older ASP files) are generated into Java code (HttpServlet), which is then compiled to .class files by the server and executed by the Java virtual machine.
    Apache Tomcat is used to deploy your Java Servlets and JSPs. So in your Java project, you can build your WAR (short for Web ARchive) file, and just drop it in the deploy directory in Tomcat.
    Although it is possible to get Tomcat to run Perl scripts and the like, you wouldn’t use Tomcat unless most of your content was Java.
    Tomcat is a Servlet and JSP Server serving Java technologies
    Note:
    The two technologies can be used together through a connector module called mod_jk. This will allow you to use the Apache HTTP server to serve regular static webpages, and the Tomcat Servlet engine to execute servlets.
  3. What are the directories under the apache-tomcat installation dir?

Answer:

conf – Server configuration files (including server.xml)
logs – Log and output files
shared – For classes and resources that must be shared across all web applications
web-apps – Automatically loaded web applications
work – Temporary working directories for web applications
temp – directory used by the JVM for temporary files (java.io.tmpdir)

  1. How to know your Apache tomcat version?
    Answer: root@ubuntu:~# /usr/share/tomcat7/bin/version.sh
    Using CATALINA_BASE: /usr/share/tomcat7
    Using CATALINA_HOME: /usr/share/tomcat7
    Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
    Using JRE_HOME: /usr/lib/JVM/java-1.7.0-OpenJDK-i386
    UsingCLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
    Server version: Apache Tomcat/7.0.26
    Server built: Apr 1 2013 08:32:04
    Server number: 7.0.26.0
    OS Name: Linux
    OS Version:2.0-105-generic-page
    Architecture: i386
    JVM Version: 1.7.0_101-b00
    JVM Vendor: Oracle Corporation
  2. Where can be set roles, username, and password?
    Answer: /conf/tomcat-users.xml
    You might also like:
    The VI Editor
    Apache Server Interview Questions & Answers
    PL/SQL Tutorial Part – 01
  3. What Is Default Session Time Out In Tomcat?
    Answer: The default session timeout 30 minutes in tomcat and can change in $TOMCAT_HOME/conf/web.xml via modifying below entry.
  4. what is the configuration file in tomcat server?
    Answer:Tomacat XML Configuration Files:
    xml(TOMCAT-HOME/conf/server.xml)
    web.xml (TOMCAT-HOME/conf/web.xml)
    tomcat-users.xml (TOMCAT-HOME/conf/tomcat-users.xml)
  5. How to change the default(8080) port number?
    Answer:Go to the tomcat>conf folder.
    Edit server.xml. )
    Search “Connector port”
    Replace “8080” by your port number.
    Restart tomcat server.
    For example, if you change the port to 1977, you would request the URL
    Note: While changing the port number make sure that port is not already in use and port no should be greater than 1024, as ports less than or equal to 1024 require superuser access to bind to.
  6. How to start and shutdown to tomcat server?
    Answer:There are two .sh file in cd $CATALINA_HOME/bin dir or in /usr/share/tomcat7/bin/
    ./startup.sh
    ./shutdown.sh
  7. How do I enable Server Side Includes (SSI)?
    Answer:
    Two things have to be done for tomcat to acknowledge SSI scripts:
    Rename $CATALINA_BASE/server/lib/servlets-SSI.renametojar to $CATALINA_BASE/server/lib/servlets-ssi.jar.
    2. Uncomment the section of web.xml found in $CATALINA_BASE/conf/web.xml that deals with SSI. it looks like this when it is uncommented:
    SSI
    org.apache.catalina.ssi.SSIServlet
    buffered 1
    debug 0
    expires 666
    isVirtualWebappRelative 0
  8. How do you define a welcome file list?
    Answer:We can define the welcome file list in web.xml deployment descriptor by using the welcome-file-list tag as shown in the following sample code:
    html
    index.htm
    index.jsp
    The actual welcome file being presented to the user shall be decided from the above list. If index.html is present then it shall be shown. If no index.html file is present in the root folder of a web application, then server tries to find a file with the name index.htm and that also fails then it finds index.jsp.
  9. What is the directory structure of a web application deployed on Tomcat?
    Answer: The typical web application structure which is deployed on tomcat is:
    Tomcat-application-structure
    The contents of the WEB-INF folder shall look like:
    web-inf
  10. Can we run multiple instances of Tomcat server on a single machine? If yes how?
    Answer:I had posted a blog entry about configuring multiple instances of tomcat on a single machine.
  11. Explain what does the MAC stands for?
    Answer:
    MAC means Medium Access Control
  12. Mention what are Catalina’s Configuration files?
    Answer:Catalina consists of configuration files are
  • policy
  • properties
  • properties
  • xml
  • xml
  • Tomcat-users.xml
  • xml
  1. How To Communicate Between Two Web Servers In Two Diff Systems?
    Answer:By using a plug module.
    it is having two containers:
    Web Container (for interpreting/executing servlets and jsps)
    EJB container(for executing EJBs).
    it can perform operations like load balancing, transaction demarcation, etc.
  2. How to communicate between two webservers in two diff systems?
    Answer:By using a plug module.
  3. Explain When To Use Ssl With Tomcat?
    Answer:You would use Tomcat to handle connection when you are running Tomcat as a stand-alone web server.
  4. Does Apache have any limits when it comes to URL aliasing and rewriting?
    Answer:No, Apache web server has no fixed limit on the total aliases and redirects that may be prompted in the configuration files.
  5. Does the installation of Apache HTTP server require SSL or PHP support?
    Answer:The answer is yes since the installation of Apache requires the support of both the SSL and PHP support.
  6. Who is responsible for Tomcat?
    Answer:The Apache Software Foundation. The Apache Software Foundation is an umbrella organization that looks after a number of Open Source projects.
    Jakarta is the group name for the Java-based projects of the Apache Software Foundation.
    Tomcat is a Web Server that handles server-side Java (in the form of Servlets and JSPs), and it’s a part of the Apache Jakarta project group. Tomcat is the “reference” implementation of the Servlet and JSP standards – in other words, if it runs under Tomcat, it should run under any compliant Servlet / JSP container.
  7. What is the web.xml configuration file?
    Answer:The web.xml file is derived from the Servlet specification and contains information used to deploy and configure the components of your web applications
  8. What is Coyote?
    Answer:Coyote is a Connector component for Tomcat that supports the HTTP 1.1 protocol as a web server. This allows Catalina, nominally a Java Servlet or JSP container, to also act as a plain web server that serves local files as HTTP documents.
    Coyote listens for incoming connections to the server on a specific TCP port and forwards the request to the Tomcat Engine to process the request and send back a response to the requesting client.
    Coyote is the HTTP connector that’s built into Tomcat and provides Tomcat with an interface that browsers can connect to.
  9. What is the engine?
    Answer:The Engine element represents the entire request processing machinery associated with a particular Catalina Service. It receives and processes all requests from one or more Connectors, and returns the completed response to the Connector for ultimate transmission back to the client.
    Exactly one Engine element MUST be nested inside a Service element, following all of the corresponding Connector elements associated with this Service.
  10. What is the host?
    Answer:The Host element represents a virtual host, which is an association of a network name for a server.
  11. What is the Context?
    Answer:The Context element represents a web application, which is run within a particular virtual host. Each web application is based on a Web Application Archive (WAR) file, or a corresponding directory containing the corresponding unpacked contents, as described in the Servlet Specification.
  12. What is Tomcat-users.xml configuration file?
    Answer:It is where the Tomcat users are defined and it is located in the conf folder of the Tomcat server root. company
  13. What is Catalina?
    Answer:Catalina is Tomcat’s servlet container. Catalina implements specifications for servlet and JavaServer Pages. Catalina is the Java Engine (JRE / JVM) that’s built into Tomcat and provides an environment in which Servlets can be run.
  14. What is Service?
    Answer:A Service element represents the combination of one or more Connector components that share a single Engine component for processing incoming requests. One or more Service elements may be nested inside a Server element.
  15. What is a Tomcat cluster?
    Answer:This component is used to manage large applications. It is used for load balancing and can be achieved through many techniques. Apache Tomcat cluster is used to manage more traffic. It provides multiples instances of the Tomcat server with its content balanced between these instances.
  16. What is the Tomcat default port?
    Answer:The default port for Tomcat is 8080. You can change the default port by editing the file server.xml under the conf folder in the Tomcat installed directory. Change the property Connector port=”8080″ to the desired port and restart Tomcat so the changes can take effect.
  17. What do you know about Tomcat history?
    Answer:Tomcat started off as a servlet reference implementation by James Duncan Davidson, a software architect at Sun Microsystems. He later helped make the project open source and played a key role in its donation by Sun Microsystems to the Apache Software Foundation. The Apache Ant software builds automation tool was developedas a side-effect of the creation of Tomcat as an open source project.
  18. What is TomEE?
    Answer:Apache TomEE (pronounced “Tommy”) is the Java Enterprise Edition of Apache Tomcat (Tomcat + Java EE = TomEE) that combines several Java enterprise projects including Apache OpenEJB, Apache OpenWebBeans, Apache OpenJPA, Apache MyFaces and others.
  19. Where do you configure a database connection pool in Tomcat server?
    Answer:The Configure pool is in the context.xml inside the conf folder of tomcat.
  20. Name some Tomcat features?
    Answer:Tomcat 7.x implements the Servlet 3.0 and JSP 2.2 specifications. It requires Java version 1.6. Tomcat 8.x implements the Servlet 3.1 and JSP 2.4 Specifications. Tomcat 8.5.x is intended to replace 8.0.x and includes new features pulled forward from Tomcat 9.0.x. Tomcat 8.5 is designed to run on Java SE 7 and later.
  21. What services are provided by Tomcat?
    Answer:Tomcat server provides a host of services which are not provided by normal web servers like Apache Web Server. Those are:
    Servlet Life cycle
    Handle Web Requests
    Database connection pooling
    Clustering
    High availability
  22. What is the difference between Tomcat and an Application server?
    Answer:Tomcat is a servlet container that supports servlets and JSP technology. An Application server supports many other Java EE technologies. Company
  23. What is a Tomcat High availability?
    Answer:A high-availability feature has been added to facilitate the scheduling of system upgrades without affecting the live environment. This is done by dispatching live traffic requests to a temporary server on a different port while the main server is upgraded on the main port. It is very useful in handling user requests on high-traffic web applications.
  24. What is the Connector?
    Answer:A Connector represents an endpoint in which requests are received.
  25. What is a servlet container?
    Answer:The servlet container is the component of a web server that interacts with Java servlets. The servlet container is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access rights.
    The servlet container handles requests to servlets, JavaServer Pages (JSP) files, and other types of files that include server-side code. The Web container creates servlet instances, loads and unloads servlets, creates and manages request and response objects, and performs other servlet-managementtasks.
    The servlet container implements the web component contract of the Java EE architecture, specifying a runtime environment for web components that includes security, concurrency, lifecycle management, transaction, deployment, and other services. Tomcat Training
  26. What is the servlet container life cycle?
    Answer:1 Servlet life cycle
    1 Servlet life cycle
    A servlet life cycle can be defined as the entire process from its creation until the destruction.
    Life cycle steps followed by a servile
    The servlet receives a request from a client through one of its connectors then is initialized by calling the init() method. The servlet calls service() method to process a client’s request and send the response. The servlet is terminated by calling the destroy() method. The servlet is garbage collected by the garbage collector of the JVM.

+42. What is a connector and why it is used in Tomcat?
Answer: The Apache Tomcat Connectors project is a part of the Tomcat project and provides web server plug-ins to connect web servers with Tomcat and other back-ends.
The supported web servers are:
The Apache HTTP Server with a plugin named mod_jk.
Microsoft IIS with a plugin named ISAPI redirector.
The iPlanet Web Server with a plugin named NSAPI redirector.

  1. What is the server?
    Answer:A Server element represents the entire Catalina servlet container. Therefore, it must be the single outermost element in the conf/server.xml configuration file. Its attributes represent the characteristics of the servlet container as a whole.
  2. What is the server server.xml configuration file?
    Answer:The server.xml file is Tomcat main configuration file, and it is responsible for specifying the Tomcat configuration on startup.
  3. How to deploy War web applications in Tomcat?
    Answer:You can drop the WAR file inside the web apps folder or use the Tomcat manager to deploy War files
  4. Can Tomcat use SSL?
    Answer:Yes, you need to make additional configurations to make Tomcat use SSL. In resume, you need to do these tasks
    Generate Keystore
    Add a connector in server.xml
    Restart Tomcat
  5. What is virtual hosting?
    Answer:This is a way of hosting more than one domain names on one server using a single IP address. This way, the single server can share its resources which may include memory, processor cycles among others to ensure its efficient use.
  6. What is Document Root?
    Answer:DocumentRoot directive is the configuration where you can specify the folder location from where the static files will be served. It’s also called as WebRoot.
  7. What is a mod_evasive module?
    Answer:mod_evasive is a third-party module that performs one simple task and performs it very well. It detects when your site is receiving a Denial of Service (DoS) attack and it prevents that attack from doing as much damage. mod_evasive detects when a single client is making multiple requests in a short period of time and denies further requests from that client. The period for which the ban is in place can be very short because it just gets renewed the next time a request is detected from that same host.
  8. What are the log files generated by Apache?
    Answer:There are two popular log files created;
    access.log – all request details with the status code
    error.log – capture all the errors within apache or connecting in the backend.
  9. What tool do you use for log analysis?
    Answer:You got to speak the truth but to give you an idea you can use GoAccess, SumoLogic or few mentioned here.
  10. What is mod_vhost_alias?
    Answer:It allows hosting multiple sites on the same server via simpler configurations.
  11. what is a difference between Apache and Nginx web server?
    Answer:Both are categorized as a Web Server and here are some of the main differences.
    Nginx is an event-based web server where Apache is process based
    Nginx is known for better performance than Apache
    Apache supports a wide range of OS where Nginx doesn’t support OpenVMS and IBMi
    Apache has a large number of modules integration with backend application server where Nginx is still catching up
    Nginx is lightweight and capturing the market share rapidly. If you are new to Nginx, then you may be interested in checking out my articles on Nginx.
  12. What is the difference between Worker and Prefork MPM?
    Answer:Both MPMs, Worker and prefork has their own mechanism to work with Apache. It totally depends on you that in which mode you want to start your Apache.
    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.
  13. What is the main configuration file of the Apache server?
    Answer:The Apache Web Server is the most commonly used web server. Before going for any interview involving web servers, make sure to go through these apache interview questions. This way you get an idea of what Apache entails. You can share your thoughts in this article with regards to the apache interview questions and the way answers are provided. Feel free to suggest more issues and solutions for the same to help others learn more about the Apache webserver.
  14. What do you mean by a valid ServerName directive?
    Answer:The DNS system is used to associate IP addresses with domain names. The value of ServerName is returned when the server generates a URL. If you are using a certain domain name, you must make sure that it is included in your DNS system and will be available to clients visiting your site.

 

  1. How to stop/start Apache Web Server?

You can restart by going to Apache instance location >> bin folder and execute apachectl script.

./apachectl stop

./apachectl startCopy

You may also use a script located in /etc/init.d/. Mostly it will be named either “apache” or “httpd”

/etc/init.d/apache stop

/etc/init.d/apache startCopy

Another procedure would be using services

httpd stop

service httpd startCopy

  1. What is the default port for HTTP and HTTPS?

The default port for HTTP is 80 and HTTPS 443. Checkout default ports for other applications listed here.

59.. Can you tell me the important configuration file name?

httpd.conf is the main configuration file used in Apache.

  1. How to check the version of running Apache Web Server?

There are multiple ways to find this but more accurately would be;

Login to a web server

Go to apache instance and bin folder

Executed httpd with -v to get the version details.

[root@lab sbin]# ./httpd -v

Server version: Apache/2.2.15 (Unix)

Server built:   Jul 18 2016 15:24:00

[root@lab sbin]#Copy

Alternatively, you can also use the rpm command to check the installed version.

[root@lab ~]# rpm -qa |grep httpd

httpd-2.2.15-54.el6.centos.x86_64

httpd-tools-2.2.15-54.el6.centos.x86_64

[root@lab ~]#Copy

61.. How to know if a web server is running?

There are multiple ways to find this.

Login to a web server and grep for “httpd” process

ps -ef |grep httpdCopy

Check for any alert in your monitoring dashboard.

Check if your apache IP:port is accessible in the browser

Ex:

Check if configured IP and port is listening on the server with netstat

netstat -anlp |grep 80Copy

  1. How to install Apache HTTP?

There are three possible ways to get this installed.

Using source code – you can download the source and compile it.

Download the latest release from

Extract the source with tar utility or gzip utility depending on the file type: .tar or .tar.gz

tar xvf  httpd-1.2.3.tar

gzip -d httpd-1.2.4.tar.gzCopy

Navigate to where you extracted the source via the cd command and configure it using the  ./configure  command on the terminal

Then compile it using the make command.

Finally, use the make install command to install it.

If you want to find out more options on how to configure it, you can make use of the configure –help command.

YUM repository – if your server is connected to the Internet or has an internal repository then you can use yum to install it.

yum install httpdCopy

RPM – You can download the necessary RPM package and use the rpm command.

rpm -ivh packagename.rpmCopy

  1. How to ensure Apache listens to only one IP address on the server?

This is often needed when you have multiple IPs on the server. To ensure Apache listens only on specified IP then you need to explicitly mention IP and port in Listen directive.

Ex:

Listen 10.10.10.10:80Copy

64.. How to ensure the Apache run with non-root/nobody user?

This is doable by adding User & Group directive in httpd.conf file

User apache

Group apacheCopy

The above configuration example will ensure it starts with “apache” user. You must ensure users exist on the server before configuring it.

  1. How do I disable directory indexing?

You can use “Options -Indexes” in the respective directory directive.

Ex:

<Directory />

Options -Indexes

</Directory>Copy

  1. Which module is required to have redirection possible?

mod_rewrite is responsible for the redirection, and this must be uncommented in httpd.conf file.

LoadModule rewrite_module modules/mod_rewrite.soCopy

  1. Can you change the listening port from default to something else?

Yes, it’s possible by specifying the port number in the Listen directive.

Ex: to make Apache listen on 9000 port to 10.10.10.10 IP address.

Listen 10.10.10.10:9000Copy

  1. How to secure a Website hosted on Apache Web Server?

There are multiple ways to secure the Apache webserver including the following.

Implementing SSL

Integrating with WAF (Web Application Firewall) like ModSecurity, etc.

Using cloud-based security provider

  1. What are the log files generated by Apache?

There are two popular log files created;

access.log – all request details with the status code

error.log – capture all the errors within apache or connecting to the backend

  1. How to create a CSR?

You can either use the following OpenSSL command or generate CSR online.

To create new CSR with a private key

openssl req -out geekflare.csr -newkey rsa:2048 -nodes -keyout geekflare.keyCopy

Check out the OpenSSL cheat sheet for more commands.

  1. What is Virtual Hosting?

Virtual Hosting in Apache allows you to host multiple websites on a single instance. You can either create IP based or Name based on virtual hosting.

  1. What module is needed to connect to WebSphere?

mod_was_ap22_http.so must be added in httpd.conf file to integrate with IBM WAS.

  1. How to put Log level in Debug mode?

Often needed when you are troubleshooting the issue and wish to capture more details. You can change the logging level to debug by ensuring the following in httpd.conf file.

LogLevel debugCopy

  1. Which module is required to enable SSL?

The mod_ssl module must be uncommented before SSL implementation.

LoadModule auth_basic_module modules/mod_ssl.soCopy

  1. What’s the WebLogic module name?

mod_wl_22.so

  1. What is the log level available in Apache?

The default configuration is set to “warn” however, the following is possible too.

  • debug
  • info
  • warn
  • notice
  • crit
  • alarm
  • emerg
  • error
  1. What is DocumentRoot?

DocumentRoot directive is the configuration where you can specify the folder location from where the static files will be served. It’s also called as WebRoot.

Default DocumentRoot location is /var/www/htmlCopy

  1. How to deploy war or JAVA applications in Apache?

I am afraid, Apache is a Web Server, and Java-based application deployment is not possible with it. However, you can integrate Java application servers like WebLogic, WebSphere, JBoss where you can deploy war, ear files.

  1. What’s a difference between Apache Web Server and Apache Tomcat?

Apache Web is an HTTP server to serve static contents where Tomcat is a servlet container to deploy JSP files.

You can always integrate Apache HTTP with Tomcat, however, based on the requirement you need to choose either one. If you need a proper web server, then Apache HTTP else Tomcat for JSP-Servlet Container.

  1. How can Apache act as a Proxy Server?

You can use a mod_proxy module to use as a proxy server. The mod_proxy module can be used to connect to the backend server like Tomcat, WebLogic, WebSphere, etc.

  1. How to configure Apache log, so it captures the time taken to serve a request?

You can add “%D” in httpd.conf file under LogFormat directive to capture the response time taken to serve the request. It will show time in microseconds.

LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\” %D” combinedCopy

Restart the Apache web server, and you can see the results.

182.19.197.23 – – [02/Oct/2019:10:32:25 +0000] “GET / HTTP/1.1” 403 4961 “-” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36” 1515

182.19.197.23 – – [02/Oct/2019:10:32:25 +0000] “GET /icons/apache_pb.gif HTTP/1.1” 304 – “http://lab.geekflare.com/” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36” 424

182.19.197.23 – – [02/Oct/2019:10:32:25 +0000] “GET /icons/poweredby.png HTTP/1.1” 304 – “http://lab.geekflare.com/” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36” 472Copy

  1. What tool do you use for log analysis?

You got to speak the truth but to give you an idea you can use GoAccess, SumoLogic or few mentioned here. Notepad++, linux shell generally is being used to analyse the log.

  1. What are the Web Servers you’ve worked on along with Apache?

Again, you better tell the truth but to make you aware, there are many web servers in the market including the following.

  • Nginx
  • Microsoft IIS
  • LiteSpeed
  • GWS
  1. How to verify httpd.conf file to ensure no configuration syntax error?

httpd –t will help you to check the syntax.

[root@lab httpd]# /usr/sbin/httpd -t

Syntax OK

[root@lab httpd]#Copy

Alternatively, you may use the apachectl command as well.

[root@lab ~]# /usr/sbin/apachectl configtest

Syntax OK

[root@lab ~]#Copy

  1. How to perform Apache performance benchmark?

You can use a tool like ApacheBench, SIEGE to perform the load test on web servers including Apache. Another option to perform stress test online to see the overall how web application performs under load.

  1. How to get support for Apache Web Server if something wrong?

Apache is an Open Source web server, so there is no enterprise-level support. However, you can raise a bug report or ask a question on Stack Overflow.

  1. How to ensure the webserver is getting started after a server reboot?

If running Linux, then you can put a script in /etc/init.d/ and enable to start on boot using chkconfig command

Let’s say you create a file called apache and put under /etc/init.d

chkconfig –add apache

chkconfig apache onCopy

if on Windows, then ensure startup type is selected “Automatic.”

  1. what is a difference between Apache and Nginx web server?

Both are categorized as a Web Server and here are some of the main differences.

Nginx is event-based web server where Apache is process based

Nginx is known for better performance than Apache

Apache supports a wide range of OS where Nginx doesn’t support OpenVMS and IBMi

Apache has a large number of modules integration with backend application server where Nginx is still catching up

Nginx is lightweight and capturing the market share rapidly. If you are new to Nginx, then you may be interested in checking out my articles on Nginx.

  1. How would you kill the Apache if graceful-stop doesn’t work?

If running on Linux, then can use kill command.

Find out the PID of Apache by using ps -ef |grep http

Then kill it

kill $PIDNUMBERCopy

if normal kill doesn’t work then try kill -9

kill -9 $PIDNUMBERCopy

If on Windows, then end the Apache task from Task Manager.

  1. How to find httpd.conf file if you don’t know the installation location?

In Linux, you can use find command.

Let’s assume, you know it must be in /apps file system then you can use the following command.

find /apps -name httpd.confCopy

But if you are not sure about which file system then you can do find on / file system but keep it in mind it may take a long time based on the overall file system size.

find / -name httpd.confCopy

  1. What are the different flavors of Apache webserver you know?

IBM HTTP Server – known as IHS and often used with IBM WebSphere Application Server

Oracle HTTP Server- known as OHS often used with Oracle Weblogic server

  1. Where is the Apache located in the data center location?

You can explain based on your experience, however, typically for Internet-facing applications, it would be in the Internet DMZ network and for intranet, core network.

But again this will differ based on application/organization.

  1. How to hide server version details in the HTTP response header?

Add the following in httpd.conf file and restart the webserver

ServerTokens Prod

ServerSignature OffCopy

This will hide the version and show the Server as “Apache” Only.

  1. What does 200, 403 & 503 HTTP error codes mean?

200 – content found and served OK

403 – tried to access restricted file/folder

503 – the server is too busy to serve the request and in other words – service unavailable.

Refer HTTP Response Code infographic for more.

  1. How to disable trace HTTP requests?

Add the following in httpd.conf file and restart the instance

TraceEnable offCopy

  1. How to troubleshoot port conflict issue?

netstat would be useful to troubleshoot the port conflict issue. If running multiple instances on a single server then it would be recommended to have absolute IP:Port configured for Listen directive.

  1. How to install the third-party module?

You can make use of Apache Toolbox. Once downloaded, extract it using the tar utility.

tar  -xf   Apachetoolbox-1.5.72.tar.gzCopy

Navigate to the folder Apachetoolbox-1.5.72 using the cd command and run the command below to select modules for your Apache server.

./install.shCopy

It provides modules such as  mod_ip_forwarding, mod_auth_mysql and mod_auth_samba to compile with the Apache webserver. Although you can include these modules manually, it is easier with Apache Toolbox.

  1. How to assign multiple names to virtual hosts?

You can make use of the ServerAlias directive as shown below.

ServerName  example.com

ServerAlias    awesome.com  fantastic.comCopy

  1. How to limit upload size?

I have a web application that allows users to upload files such as word documents, pdf and so on.  How do I limit file upload by users?

You can make use of the LimitRequestBody directive to limit upload file size.

<Directory “usr/local/apache2/uploads”>

LimitRequestBody 9000

</Directory>Copy

The value assigned to the LimitRequestBody allows Apache to accept and store file uploads of 9000 bytes by users. You can adjust the value based on the requirement.

  1. How to restrict access by IPs?

You may want some of the context root to be accessible by allowed IPs. To do so, you can make use of mod_authz_core or mod_authz_host modules to restrict access using the Require directive.

Require 10.0.0.2 10.0.0.4 192.168.34.23 192.168.34.23. By doing the above, Apache will serve requests only if requests are made from the listed IPs.

You need to specify the Require directive within the directory where you want to allow or deny access to resources.

Related Posts:

For more Interview Questions And Answers click here