Friday, 29 September 2017

Important Interview Questions and Answers on Apache Web Server

Q1:-How can we stop/start Apache Web Server?
Ans:-You can restart by going to Apache instance location >> bin folder and execute apachectl script.

./apachectl stop
./apachectl start

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

/etc/init.d/apache stop
/etc/init.d/apache start

Another procedure would be using services

service httpd stop
service httpd start

Q2:-What is the default port for HTTP and HTTPS? 

Ans:-The default port for HTTP is 80 and HTTPS 443.

Q3:-Which is the most important configuration file for Apache Web Server? 

Ans:- httpd.conf is the main configuration file used in Apache.

Q4:-How can we check the version of running Apache Web Server? 

Ans:- Below is the way to get the version of Apache Web Server
1st Method:-
# ./httpd -v
Server version: Apache/2.2.15 (Unix)
Server built:   Jul 18 2016 15:24:00

2nd Method:-
# rpm -qa |grep httpd

Q5:-How can we check that  web server is running or not? 

Ans:- ps -ef |grep httpd

Q6:-How can we  install Apache web server? 

Ans:- By yum or rpm package installer

yum -y install httpd
rpm -ivh packagename.rpm

Q7:-How can we ensure that Apache listen on only one IP on the server?
Ans:-This is often needed when you have multiple IPs on the server. In order to ensure Apache listen only on specified IP then you need to explicitly mention IP and port in Listen directive.

Example:- Listen

Q8:-How can we ensure that Apache process is running with non-root user? 

Ans:- by adding User & Group directive in httpd.conf file

User apache
Group apache

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

Q9:- How do I disable directory indexing? 

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

<Directory />
       Options -Indexes

Q10:-Which module is required to have redirection possible? 

Ans:- mod_rewrite is responsible for the redirection and this must be un-commented in httpd.conf file.

LoadModule rewrite_module modules/

Q11:-Can you change the listening port from default to something else? 

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

Example:- To make Apache listen on 9000 port to IP address.

Q12:-How to secure Website hosted on Apache Web Server? 

Ans:- By implemented SSL or intregrated WAF (Web Application Firewall)

Q13:-What are the log files generated by Apache? 

Ans:-There are two log files created by Apache
1) access.log – all request details with the status code
2) error.log – capture all the errors within apache or connecting in backend

Q14:-How to create a CSR? 

Ans:- By openssl command

Example:-To create new CSR with private key
openssl req -out mynewweb.csr -newkey rsa:2048 -nodes -keyout mynewweb.key

Q15:-What is Virtual Hosting? 

Ans:-Apache allows us to host multiple websites on a single instance. We can either create IP based or Name based in virtual hosting.

Q16:-What module is needed to connect to WebSphere? must be added in httpd.conf file to integrate with IBM WAS.

Q17:-How to put Log level in Debug mode? 

Ans:-We can change the logging level to debug by changing the following in httpd.conf file.
LogLevel debug

Q18:-Which module is required to enable SSL? 

Ans:- mod_ssl module must be uncommented prior to SSL implementation.
LoadModule auth_basic_module modules/

Q19:-What’s the WebLogic module name? 


Q20:-What are the log level available in Apache? 

Ans:-Below are the log level available in Apache
Note:-The default configuration is set to “warn”.   

Q21:-What is DocumentRoot? 

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

Default DocumentRoot location is /var/www/html

Q22:-How to deploy war or JAVA applications in Apache? 

Ans:-We can integrate Java application server like WebLogic, WebSphere, JBoss by deploy the war, ear files in /webapp/ folder and take a restart of web server

Q23:-What’s difference between Apache Web Server and Apache Tomcat? 

Ans:- Apache Web is HTTP server to serve static contents where Tomcat is servlet container to deploy JSP files.

Q24:-How can Apache act a Proxy Server? 

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

Q25:-How to configure Apache log so it captures time taken to serve a request?

Ans:- We 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" combined

Restart the apache web server after change .

Q26:-What tool do you use for log analysis? 

Ans:-You got to speak the truth but to given you an idea you can use GoAccess, SumoLogic or few mentioned here.

Q27:-What are the Web Servers available ?

Ans:- Below are the few web servers list
    Microsoft IIS

Q28:-How to verify httpd.conf file to ensure no configuration syntax error? 

Ans:- httpd –t will help you to verify the syntax.

#/usr/sbin/httpd -t
Syntax OK

Alternatively, you may use apachectl command as well.

#/usr/sbin/apachectl configtest
Syntax OK

Q29:-How to perform Apache performance benchmark? 

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

Q30:-How to ensure web server is getting started after server reboot? 

Ans:-In Linux, you can put start script in /etc/init.d/ and enable to start on boot using chkconfig command

chkconfig --add apache
chkconfig apache on

In Windows, selected “Automatic” start of service

Q31:-what is a difference between Apache and Nginx web server? 

Ans:- 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 wide range of OS where Nginx doesn’t support OpenVMS and IBMi
 Apache has 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 to check out my articles on Nginx.

Q32:-How would you kill the Apache process if graceful stop doesn’t work? 

Ans:-In Linux, use kill command to stop the Apache process
Find out the PID of Apache by using command
ps -ef |grep http

Then kill it

In Windows,you can end the apache task from Task Manager.

Q33:-How to find httpd.conf file if you don’t know installation location? 

Ans:- By find or locate command
find / -name httpd.conf -type f 2>/dev/null
locate httpd.conf           

Q34:-What are the different flavor of Apache web server you know? 

Ans:- IBM HTTP Server (IHS)– used with IBM WebSphere Application Server
      Oracle HTTP Server (OHS)- used with Oracle Weblogic server

Q35:-How to hide server version details in HTTP response header? 

Ans:- Add the following in httpd.conf file and restart the web server

ServerTokens Prod
ServerSignature Off
This will hide the version and show Server as “Apache” Only.

Q36:-What does 200, 403 & 503 HTTP error code mean?
 Ans:-   200 – content found and served OK
    403 – tried to access restricted file/folder
    503 – server is too busy to serve the request and in another word – service unavailable.
    Refer HTTP Response Code infographic for more.

Q37:-How to disable trace HTTP request?

Ans:-Add the following in the httpd.conf file and restart the instance
TraceEnable off

Q38:-How to troubleshoot port conflict issue? 

Ans:-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 in Listen directive.

Related Topics :-
Important Interview Question and Answer on Shell ScriptingImportant Interview Question and Answer on PLSQL
Important Interview Question and Answer on SQL

1 comment:

  1. Nice post. I learn something new and challenging on sites I stumbleupon everyday. It’s always helpful to read through articles from other writers and practice a little something from their websites.

    Please Read More: Download Ebook: Ultimate Guide To Job Interview Questions Answers:

    Best rgs


Cloning database with RMAN

Below are the steps to clone production database(primedb) to UAT database(clonedb)   STEP1 :- Check the both servers are able to connect ...