Apache Web Server Interview Questions

Apache Web Server Interview Questions

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.

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.

What’s difference between Apache Web Server and Apache Tomcat?

Apache Web is HTTP server to serve static contents where Tomcat is 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 proper web server then Apache HTTP else Tomcat for JSP-Servlet Container.

How to install Apache web server?

There are three possible ways to get this installed.

1.      Using source code – you can download the source and compile it.
2.      YUM repository – if your server is connected to the Internet or have internal repository then you can use yum to install it.
yum install httpd
3.      RPM – You can download the necessary RPM package and use rpm command.
rpm -ivh packagename.rpm

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

What is the default port for HTTP and HTTPS?

The default port for HTTP is 80 and HTTPS 443.

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

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

httpd stop
service httpd start

How do you find which version of Apache Web Server you are using?

There is multiple ways to find this.
Just run the following command in bin directory of Apache web server, it will display the version

$ ./apache.sh version
·         Login to 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:   Jan 10 2018 15:24:00
[root@lab sbin]#

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 ~]# 

What is the difference between a restart and a graceful restart of a web server?

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.

What is DocumentRoot?

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

How to restart Apache web server?

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.

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.

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

Yes, it’s possible by specifying the port number in Listen directive.
For ex: to make Apache listen on 5000 port to 11.11.11.11 IP address.

Listen 11.11.11.11:5000

How to secure Website hosted on Apache Web Server?

There are multiple ways to secure the Apache web server including the following.
·         Implementing SSL
·         Integrating with WAF (Web Application Firewall) like ModSecurity, etc.
·         Using cloud-based security provider

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 in backend

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 in virtual hosting.

What are 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


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

What are the different flavors of Apache web server 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

What do 200, 403 & 503 HTTP error code mean?

·         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.

If you have only one IP address, but you want to host two web sites on your server. What will you do?

In this case I will use Name Based Virtual hosting.

ServerName 10.110.204.21
NameVirtualHost *:80
<VirtualHost *:80>

ServerName mysite1.piyush.com
DocumentRoot /var/www/html/ mysite 1
</VirtualHost>
<VirtualHost *:80>

ServerName mysite2.piyush2.com
DocumentRoot /var/www/html/ mysite2
</VirtualHost>



Comments

Popular posts from this blog

પટેલ સમાજનો ઈતિહાસ જાણો : કોણ અને ક્યાંથી આવ્યા હતા પાટીદારો

Python HTML Generator using Yattag Part 1

Java Event Delegation Model, Listener and Adapter Classes