We are very grateful to all our readers for replying to our new Linux interview chapter. now we have started to learn about the interview questions and the chapters on the basic to intermediate Apache interview questions that we are paying attention to today. This will help you prepare for the interview.
Apache Job Interview Questions
This section covers 25 interesting questions that will be asked during an Apache job interview with their answers, therefore, you can easily understand some new things about Apache that you have never seen before.
Before you begin to read this article, we strongly recommend that you do not stick to it. You should first try to understand everything in actual scenarios.
1. What is an Apache web server?
Answer: Apache web Server HTTP is a popular, powerful, and open-source server that manages web sites and provides web file services to the network. it runs based on HTTP Hypertext Transfer Protocol, which provides the standard for communication between the server and the client web browser. it supports SSL, CGI files, and many other features of the VM.2. If you check Apache and its version?
Answer: first, run the rpm command to check whether Apache has been installed. If it has been installed, run the httpd-v command to get its version.
[root@tecmint ~]# rpm -qa | grep httpdhttpd-devel-2.2.15-29.el6.CentOS.i686httpd-2.2.15-29.el6.centos.i686httpd-tools-2.2.15-29.el6.centos.i686
[root@tecmint ~]# httpd -vServer version: Apache/2.2.15 (Unix)Server built: Aug 13 2013 17:27:11
3. Which user does Apache run? Where is the main configuration file located ?.
Answer: Apache runs with "nobody" users and httpd daemon. the main configuration files of Apache are:/etc/httpd/conf/httpd. conf (CentOS/RHEL/Fedora) and/etc/apache2.conf (Ubuntu/Debian ).4. Does Apache listen for http and https requests?
Answer: Apache listens for http on port 80 by default and https on port 443 (an SSL integer is required). You can also use the netstat command to check the port.
[root@tecmint ~]# netstat -antp | grep httptcp 0 0 :::80 :::* LISTEN 1076/httpd tcp 0 0 :::443 :::* LISTEN 1076/httpd
5. How to install the Apache server on your Linux machine?
Answer: very simple. You can use any yum on (RHEL/CentOS/Fedora) and apt-get On (Debian/Ubuntu) to install the Apache server on your Linux.
[root@tecmint ~]# yum install httpd
[root@tecmint ~]# apt-get install apache2
6. Where can you find all the configuration paths of the Apache Web server?
Answer: The default configuration path of Apache is put in: (RHEL/CentOS/Fedora) in/etc/httpd/on and (Debian/Ubuntu) in/etc/apache2.
[root@tecmint ~]# cd /etc/httpd/[root@tecmint httpd]# ls -ltotal 8drwxr-xr-x. 2 root root 4096 Dec 24 21:44 confdrwxr-xr-x. 2 root root 4096 Dec 25 02:09 conf.dlrwxrwxrwx 1 root root 19 Oct 13 19:06 logs -> ../../var/log/httpdlrwxrwxrwx 1 root root 27 Oct 13 19:06 modules -> ../../usr/lib/httpd/moduleslrwxrwxrwx 1 root root 19 Oct 13 19:06 run -> ../../var/run/httpd
[root@tecmint ~]# cd /etc/apache2[root@tecmint apache2]# ls -ltotal 84-rw-r--r-- 1 root root 7113 Jul 24 16:15 apache2.confdrwxr-xr-x 2 root root 4096 Dec 16 11:48 conf-availabledrwxr-xr-x 2 root root 4096 Dec 16 11:45 conf.ddrwxr-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 magicdrwxr-xr-x 2 root root 12288 Dec 16 11:48 mods-availabledrwxr-xr-x 2 root root 4096 Dec 16 11:48 mods-enabled-rw-r--r-- 1 root root 315 Jul 21 02:14 ports.confdrwxr-xr-x 2 root root 4096 Dec 16 11:48 sites-availabledrwxr-xr-x 2 root root 4096 Dec 6 00:04 sites-enabled7. Can Apache be fixed by the TCP package?
Answer: No. It cannot be fixed by the TCP package because it does not support Linux libwrap..8. How can I change the default port in Apache and how can I listen for commands in Apache?
Answer: in httpd. the conf file contains the command "Listen", which allows us to change the default Apache port. with the help of the Listen command, we can perform Apache listening on different ports and different interfaces.
If you have multiple IP addresses registered on your Linux server and want Apache to receive HTTP requests on a special Ethernet port or interface, you can use the Listen command to do this.
To change the default port of Apache, open your Apache main configuration file httpd. conf or apache2.conf.
[root@tecmint ~]# vi /etc/httpd/conf/httpd.conf[root@tecmint ~]# vi /etc/apache2/apache2.conf
Search for the word "Listen", comment out the original line, and write your own commands under that line.
# Listen 80Listen 8080ORListen 172.16.16.1:8080
Save the file and restart the web server.
[root@tecmint ~]# service httpd restart[root@tecmint ~]# service apache2 restart9. Can we put two Apache Web servers on one machine?
Answer: Yes. We can run two different Apache servers on a Linux machine at the same time, but the condition is that they should listen on different ports, however, we can use the Listen command of Apache to change the port.10. Do you know what Apache DocumentRoot means?
Answer: Apache of DocumentRoot refers to the storage location of web files on the server. The default DocumentRoot is/var/www/html or/var/www. this can be modified. You only need to modify the virtual host configuration "DocumentRoot" in the host.11. How to manage files under different folders? What is the Alias command?
Answer: Yes, this can be done by using the Alias command in the main Apache configuration file. the Alias command can be used to search for resources in the file system. It uses a URL path and replaces it with a file or directory redirected to the system.
Use the Alias command, which is part of the mod_alias module of Apache. The default syntax of the Alias command is:
Alias /images /var/data/images/
In the above example, the/images url prefix in/var/data/images indicates that the client request "http://www.example.com/images/sample-image.png” will get the/var/data/images/sample-image.png on the Apache server to retrieve the “sample-image.png File. it is also called URL ing.12. How do you understand "DirectoryIndex?
Answer: DirectoryIndex is the file that Apache first searches for when there is a request from the host. for example, when a client sends a request to www.example.com, Apache searches for the index file in the root directory of the site file (the file to be displayed first ).
The default setting of DirectoryIndex is. html index.html index. php. If this is not the name, you need. modify the DirectoryIndex value in conf or apache2.conf to display it on 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 .exe13. How can I Invalidate the directory list when the index file is lost?
Answer: If the main index file in the root directory of the site fails, Apache will list all files with similar content in the browser to replace the site homepage.
To disable the Apache directory list, you can set global settings in the main configuration file or some of the following rules in the. htaccess file.
<Directory /var/www/html> Options -Indexes</Directory>
14. What are some different log files on the Apache Web server?
Answer: The default log files of the Apache Web Server are access logs "/var/log/httpd/access_log" and error logs:/var/log/httpd/error_log ".15. How do you understand the "connection reset by peer" in the error log?
Answer: when the server is providing services to the request, the end user will interrupt the connection and we will see "connection reset by peer" in the error log.16. What is an Apache Virtual Host?
Answer: The information contained in the VM includes the site name, document root path, Directory Index, server administrator email address, and error log file path.
You can add the commands you need for your domain at will, but to run a site, you must configure at least a number of parameter server names and the document root directory. On Linux machines, we usually set the relevant configurations of our VM at the end of the httpd. conf file.Virtual Host example
<VirtualHost *:80> ServerAdmin email@example.com 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: usually refers to the email address of the website owner. Errors and notifications can be sent to the website owner.
DocumentRoot: the location where web files are stored on the server (required ).
ServerName: The domain name used to access the site through a browser (required ).
ErrorLog: Location of the log file, which records all logs related to the site.
<Location> is used to set elements related to the address bar of the URL/web server.
<Directory> indicates the location of an object on the server in the file system.
Answer: Apache virtual hosting refers to hosting multiple web sites on a single web server. Apache can set two types of virtual hosts: Name-based virtual hosting and IP-based virtual host hosting.
For more information, see How to Create a Name/IP-based VM in Apache.19. How do you understand Apache MPM?
Answer: MPM refers to Multi Processing Modules, which is actually a mechanism followed by Apache to accept and complete requests to the web server.20. What is the difference between Worker and Prefork MPM?
Answer: they are all MPM, and Worker and prefork have their respective running mechanisms on Apache. They fully depend on the mode in which you want to start your Apache.
The basic difference between Worker and MPM is that they generate the processing process of sub-processes. in Prefork MPM, a master httpd is started. This master Process manages all other sub-processes to provide services for client requests. when an httpd process is activated in worker MPM, different threads are used to provide services for client requests.
Prefork MPM uses multiple sub-processes. Each process has one thread while worker MPM uses multiple sub-processes. Each process has multiple threads.
In the Prefork MPM, each process processes a connection at a time and each thread processes a connection at a time in the Worker mpm.
Memory usage Prefork MPM occupies a large amount of memory, while Worker occupies a smaller memory.
Answer: The LimitRequestBody command is used to limit the upload size.
For example, to add a 100000-byte limit to the/var/www/html/tecmin/uploads directory, add the following command to the Apache configuration file.
<Directory "/var/www/html/tecmint/uploads">LimitRequestBody 100000</Directory>22. What are mod_perl and mod _ php?
Mod_perl is an Apache module compiled along with Apache. It is used for simple integration of Perl scripts and improves its performance.
Mod_php is used for simple integration of PHP scripts on web servers. It is embedded with the PHP interpreter in the Apache process. it forces Apache sub-processes to use more memory and can only be used on Apache, but it is still very popular.
Answer: It is a third-party module that protects your web server from web attacks such as DDOS, because it only executes one task at a time, and all the operations are good.
For more confidence, please read this article, which will guide you how to install and configure mod_evasive in Apache.24. What is Loglevel debugging in the httpd. conf file?
Answer: with the help of the Loglevel Debug option, we can obtain or record more information in the error log to help us Debug the problem.25. What is the use of mod_ssl and how does SSL work in Apache?
A: Mod_ssl is an Apache module that enables Apache to establish connections and transmit data in a secure encryption environment. Using an SSL Certificate, all login information and other important confidential information are transmitted over the Internet encrypted, which prevents data theft or IP spoofing.How to use SSL in Apache
Apache performs the following three steps whenever an https request arrives:
Apache generates its private key and converts it to A. CSR file (certificate issuing request ).
Then Apache sends the. csr file to CA (Certificate Management Center ).
CA receives the. csr file, converts it to. crt (certificate), and then sends it back to Apache to complete the https connection request.
This is the most popular 25 questions asked by the interviewer. Please share the interview questions you have recently asked in the comments below to help other interviewers.