Home  >  Article  >  Backend Development  >  25 beginner-intermediate interview questions about apache

25 beginner-intermediate interview questions about apache

伊谢尔伦
伊谢尔伦Original
2016-11-25 15:27:23883browse

Apache Job Interview Questions

This section covers 25 interesting Apache job interview questions, along with their answers, so you can easily understand some that you may have never seen before. New things about Apache.

Before you start reading this article, we strongly recommend that you do not memorize it by rote, but first try to understand everything in actual scenarios.

1. What is Apache web server?

Answer: Apache web server HTTP is a very popular, powerful and open source tool for managing web sites and serving web files to the network. It runs on the HTTP Hypertext Transfer Protocol, which provides server and client web A standard for browser communication. It supports SSL, CGI files, virtual hosts and many other features.

2. How to check Apache and its version?

Answer: First, use the rpm command to check whether Apache is installed. If it is already installed, use the httpd -v command to check its version.

[root@tecmint ~]# rpm -qa | grep httpd
httpd-devel-2.2.15-29.el6.centos.i686
httpd-2.2.15-29.el6.centos.i686
httpd-tools-2.2.15-29.el6.centos.i686
[root@tecmint ~]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Aug 13 2013 17:27:11

3. Which user does Apache run as? Where is the location of the main configuration file?.

Answer: Apache runs as "nobody" user and The httpd daemon is running. The main Apache configuration files are: /etc/httpd/conf/httpd.conf (CentOS/RHEL/Fedora) and /etc/apache2.conf (Ubuntu/Debian).

4. Apache listening http and https requests?

Answer: Apache listens on port 80 for http and https on port 443 by default (requires SSL integer). You can also use the netstat command to check the ports.

[root@tecmint ~]# netstat -antp | grep http
tcp 0 0 :::80 :::* LISTEN 1076/httpd
tcp 0 0 :::443 :::* LISTEN 1076/httpd

5. How to configure the port on your Linux Install Apache server on your machine?

Answer: Very simple, you can use anything like yum on (RHEL/CentOS/Fedora) and apt-get on (Debian/Ubuntu) to install 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 in: (RHEL/CentOS/Fedora) in /etc/httpd/ on and (Debian/Ubuntu ) is under /etc/apache2.

[root@tecmint ~]# cd /etc/httpd/
[root@tecmint httpd]# ls -l
total 8
drwxr-xr-x. 2 root root 4096 Dec 24 21:44 conf
drwxr-xr-x. 2 root root 4096 Dec 25 02:09 conf.d
lrwxrwxrwx 1 root root 19 Oct 13 19:06 logs -> ../../var/log/httpd
lrwxrwxrwx 1 root root 27 Oct 13 19:06 modules -> ../../usr/lib/httpd/modules
lrwxrwxrwx 1 root root 19 Oct 13 19:06 run -> ../../var/run/httpd
[root@tecmint ~]# cd /etc/apache2
[root@tecmint apache2]# ls -l
total 84
-rw-r--r-- 1 root root 7113 Jul 24 16:15 apache2.conf
drwxr-xr-x 2 root root 4096 Dec 16 11:48 conf-available
drwxr-xr-x 2 root root 4096 Dec 16 11:45 conf.d
drwxr-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 magic
drwxr-xr-x 2 root root 12288 Dec 16 11:48 mods-available
drwxr-xr-x 2 root root 4096 Dec 16 11:48 mods-enabled
-rw-r--r-- 1 root root 315 Jul 21 02:14 ports.conf
drwxr-xr-x 2 root root 4096 Dec 16 11:48 sites-available
drwxr-xr-x 2 root root 4096 Dec 6 00:04 sites-enabled

7. Can Apache be fixed by TCP wrapper?

Answer: No, it cannot be fixed by TCP wrapper because it does not support Linux libwrap.a library .

8. How to change the default port in Apache, and how does the listening command work?

Answer: There is a directive "Listen" in the httpd.conf file that allows us to change the default Apache port. In Listen With the help of commands we can perform Apache listening on different ports and different interfaces.

Suppose you have multiple IPs registered to your Linux machine and want Apache to receive HTTP on a special Ethernet port or interface Request, even this requirement can be done with the Listen directive.

In order to change the default port of Apache, please 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

Look for the word "Listen" , comment out the original line and write your own instructions below that line.

# Listen 80
Listen 8080

OR

Listen 172.16.16.1:8080

Save the file and restart the web server.

[root@tecmint ~]# service httpd restart
[root@tecmint ~]# service apache2 restart

9. We can put two Apache web servers on one machine ?

Answer: Yes, we can run two different Apache servers on one Linux machine at the same time, but the condition is that they should listen on different ports, and we can use Apache’s Listen directive to change the port.

10. Do you know what Apache’s DocumentRoot means?

Answer: DocumentRoot of Apache means the storage location of web files on the server. The default DocumentRoot is /var/www/html or /var/www. This can be To modify, just modify the virtual host configuration "DocumentRoot" in the host.

11. How to manage files in different folders, and what is the Alias ​​command?

Answer: Yes, this can be done with the help of the host The Alias ​​directive in the Apache configuration file does this. The Alias ​​directive can search for resources in the file system. It uses a URL path and replaces it with a redirect to a file or directory on the system.

Using the Alias ​​directive, it Part of Apache's mod_alias module. The default syntax for the Alias ​​directive is:

Alias ​​/images /var/data/images/

上面的示例中, 放在/var/data/images 前缀前面的 /images url的意思是客户端请求“http://www.example.com/images/sample-image.png” 会让Apache从服务器上的/var/data/images/sample-image.png 取 “sample-image.png” 文件. 它也被称为URL 映射.

12. 对于“DirectoryIndex”你是怎么理解的?

答案 : DirectoryIndex 是当有一个来自主机的请求时Apache首先会去查找的文件. 例如: 客户端发送请求www.example.com, Apache 对此将到站点的文件根目录查找index文件 (首先要展示的文件).

DirectoryIndex 的默认设置是 .html index.html index.php, 如果不是这个名字, 你需要对 httpd.conf 或者 apache2.conf 中的 DirectoryIndex 值做出修改,以将其展示在你的客户端浏览器上.

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

13. 当index文件丢失时如何使目录列表失效?

答案 : 如果站点根目录中的主index文件失效, 那么Apache将会在浏览器上列出所有内容类似的文件,以替换站点主页.

为了关闭Apache目录列表, 你可以在主配置文件中全局的设置,或者在.htaccess文件中部分的设置如下规则.

<Directory /var/www/html>
Options -Indexes
</Directory>

14. Apache Web 服务器有些什么不同的日志文件?

答案 : Apache Web 服务器的默认日志文件是访问日志 “/var/log/httpd/access_log” 和错误日志:/var/log/httpd/error_log”.

15. 你是怎样理解错误日志中的“connection reset by peer”的?

答案 : 当服务器正在向请求提供服务时终端用户中断连接, 我们就会在错误日志中看到“connection reset by peer“.

16. 什么是Apache的虚拟主机?

答案 : 虚拟主机部分包含的信息包括站点名称,文档根路径,目录索引,服务器管理员邮箱,错误日志文件路径等等。

你可以随意为你的域添加你需要的指令,但是要运行一个站点,至少要配置量个参数服务器名称和文档根目录。 在Linux机器上,通常我们在httpd.conf文件的末尾来设定我们的虚拟主机部分的相关配置。

虚拟主机示例

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.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 : 通常是指站点拥有者的电子邮箱,错误和通知可以发到里面。

DocumentRoot : web文件在服务器上存放位置(必须配置).

ServerName : 通过浏览器访问站点时的域名(必须配置).

ErrorLog : 日志文件的位置,里面记录了所有与该站点相关的日志。

17. a625b56ea89673a6f0f85653dfc11837和7b799fe73e35dcfdc019b13f54de80e5之间有什么区别?

答案 :

a625b56ea89673a6f0f85653dfc11837 是用来设定和URL/ web服务器的地址栏相关的元素的。

7b799fe73e35dcfdc019b13f54de80e5 是指服务器上某对象在文件系统中的位置

18. 什么是Apache虚拟托管?

答案 : Apache虚拟托管是指,在单个web服务器上托管多个web站点。Apache 可以设定两种类型的虚拟主机:基于名称的虚拟托管和基于IP的虚拟主机托管。

更多相关信息,请参阅 如何在Apache中创建基于Name/IP的虚拟主机。

19. 你怎么理解Apache的MPM?

答案 : MPM意思是Multi Processing Modules,实际上是指Apache遵循的一些机制,用来接受和完成对web服务器的请求。

20.  Worker 和 Prefork MPM之间的区别是什么?

答案 : 它们都是MPM, Worker 和 prefork 有它们各自在Apache上的运行机制. 它们完全依赖于你想要以哪一种模式启动你的Apache.

Worker 和 MPM基本的区别在于它们产生子进程的处理过程. 在Prefork MPM中, 一个主httpd进行被启动,这个主进程会管理所有其它子进程为客户端请求提供服务. 而在worker MPM中一个httpd进程被激活,则会使用不同的线程来为客户端请求提供服务.

Prefork MPM 使用多个子进程,每一个进程带有一个线程而 worker MPM 使用多个子进程,每一个进程带有多个线程.

Prefork MPM中的连接处理, 每一个进程一次处理一个连接而在Worker mpm中每一个线程一次处理一个连接.

内存占用 Prefork MPM 占用庞大的内存, 而Worker占用更小的内存.

21. “LimitRequestBody”的应用是什么,还有如何在你的上传中加入限制?

答案 : LimitRequestBody 指令被用来在上传大小上做一个限制.

例如: 我想要在 /var/www/html/tecmin/uploads目录中加入 100000 字节的限制. 那么你就需要在Apache配置文件中加入下面的指令.

<Directory "/var/www/html/tecmint/uploads">
    LimitRequestBody 100000
</Directory>

22. mod_perl 和 mod _php 是什么?

答案:

mod_perl 是一个随同Apache一起编译的Apache模块,用来做Perl脚本的简单集成并提升其性能.

mod_php 用来做web服务器PHP脚本的简单集成, 它在Apache进程中嵌入了PHP解释器. 它强制Apache子进程使用更多的内存,并且只能在Apache上使用,但是仍然很流行.

23. Mod_evasive是什么?

答案: 它是一个保护你的web服务器不受像DDOS之类的web攻击的第三方模块,因为它一次只执行一个任务,所有执行得很不错.

更多信息,请阅读这篇文章, 它会指导你 如何在Apache中安装并配置mod_evasive.

24. httpd.conf文件中的Loglevel调试是什么?

答案 : 在Loglevel Debug 选项的帮助下, 我们可以在错误日志中获取或者记录更多的信息,以帮助我们调试问题.

25. mod_ssl 有什么用以及SSL在Apache中如何工作?

回答: Mod_ssl 是一个Apache模块, 它使Apache可以在一个安全的加密环境中建立连接和传输数据。 使用SSL证书,所有的登录信息和其他重要的保密信息都会以加密的方式在Internet上进行传输,这会防止我们的数据被窃取或IP欺骗。

怎样在Apache中使用SSL

每当https请求到达,Apache都会执行以下三步:

Apache生成它的私钥并且将私钥转换为.CSR 文件 (证书签发请求).

然后Apache发送 .csr 文件给 CA (证书管理中心).

CA 收到.csr 文件 并转换为 .crt (证书) 然后再发回给Apache 来完成https连接请求.

这就是目前被面试官问到的最流行的25的问题, 请在下面评论部分分享你最近面试被问到的面试问题来帮助其他其他面试者。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn