Linux Admin教程

Linux Install Apache

在本章中,我们将了解 Apache HTTP Server 如何产生的背景,然后在 CentOS Linux 7 上安装最新的稳定版本。
Apache 是一个已经存在很长时间的网络服务器。其实几乎和http本身存在一样!
Apache 最初是国家超级计算应用中心(也称为 NCSA)的一个相当小的项目。在 90 年代中期,所谓的"httpd"是迄今为止互联网上最受欢迎的网络服务器平台,拥有大约 90% 或更多的市场份额。
此时,这是一个简单的项目。熟练的IT称为网站管理员的工作人员负责:维护网络服务器平台和网络服务器软件以及前端和后端站点开发。 httpd 的核心是它能够使用称为插件或扩展的自定义模块。一位网站管理员也足够熟练,可以为核心服务器软件编写补丁。
在 90 年代中后期的某个时候,httpd 的高级开发人员和项目经理离开 NCSA 去做其他事情。这让最流行的网络守护进程处于停滞状态。
由于 httpd 的使用如此广泛,一群经验丰富的 httpd 网站管理员呼吁召开一次峰会,讨论 httpd 的未来。决定将最好的扩展和补丁协调并应用到当前的稳定版本中。于是,现在的 http 服务器之父诞生了,并被命名为 Apache HTTP Server。
鲜为人知的历史事实-Apache 并非以美洲原住民部落的战士命名。事实上,它的创造和命名是有曲折的:由许多有才华的计算机科学家的许多修复(或补丁)组成: patchyApache

在 CentOS Linux 7 上安装当前稳定版本

第 1 步-通过 yum 安装 httpd。
yum-y install httpd
此时 Apache HTTP Server 将通过 yum 安装。
第 2 步-编辑特定于您的 httpd 需求的 httpd.conf 文件。
在默认的 Apache 安装中,Apache 的配置文件名为 httpd.conf,位于 /etc/httpd/。所以,让我们在 vim 中打开它。
httpd.conf 的前几行在 vim 中打开-
# 
# this is the main Apache HTTP server configuration file.  It contains the 
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information. 
# In particular, see  
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html> 
# for a discussion of each configuration directive.
我们将进行以下更改,以允许我们的 CentOS 安装服务来自 http 端口 80 的 http 请求。

监听主机和端口

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
从这里开始,我们将 Apache 更改为侦听某个端口或 IP 地址。例如,如果我们想在诸如 8080 之类的替代端口上运行 httpd 服务。或者如果我们的网络服务器配置了具有不同 IP 地址的多个接口。

听着

防止 Apache 附加到每个 IP 地址上的每个侦听守护程序。这对于停止仅指定 IPv6 或 IPv4 流量很有用。甚至绑定到多宿主主机上的所有网络接口。
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
Listen 10.0.0.25:80
#Listen 80

文档根目录

"文档根"是默认目录,Apache 将在其中查找索引文件以在访问您的服务器时为请求提供服务:http://www.yoursite.com/ 将从您的文档根目录检索并提供索引文件。
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"
第 3 步-启动并启用 httpd 服务。
[root@centos rdc]# systemctl start httpd && systemctl reload httpd 
[root@centos rdc]#
第 4 步-配置防火墙以允许访问端口 80 请求。
[root@centos]# firewall-cmd--add-service=http--permanent
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4