安装Apache服务
rpm -qa | grep -i httpd #检查是否安装了Apache服务器软件
yum -y install httpd* #安装Apache服务器软件
systemctl start httpd #启动httpd服务程序
systemctl enable httpd #将httpd服务程序加入到开机自动启动列表
firewall-cmd --permanent --add-service=http #永久允许http
firewall-cmd --permanent --add-service=https #永久允许https
firewall-cmd --reload #重新加载防火墙策略
在本机的浏览器上输入127.0.0.1:80(或者本机ip:80)测试其是否正常运行。如果可以阅读此页面,这意味着该网站正常工作。
配置Apache服务
● Apache服务常见配置文件介绍
| 文件名称 | 作用 |
|---|---|
| /etc/httpd/conf | 主配置目录 |
| /etc/httpd/conf/httpd.conf | 主配置文件 |
| /etc/httpd/conf.d | 子配置目录 |
| /etc/httpd/conf.d/*.conf | 子配置文件 |
| /var/www/html | 默认发布目录 |
| index.html | 默认发布文件 |
| 80 | 默认端口 |
| httpd_sys_content_t | 默认安全上下文 |
| apache | 程序开启默认用户 |
| /etc/httpd/logs | 默认日志文件位置 |
| /var/log/httpd/access_log | 访问日志 |
| /var/log/httpd/error_log | 错误日志 |
| /etc/httpd/modules | 模块文件路径链接 |
| /etc/httpd/bin/ | 二进制命令 |
● Apache主配置文件介绍
在httpd服务程序的主配置文件中,存在三种类型的信息:注释行信息、全局配置、区域配置。位置:/etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd" #全局配置
<Directory "/var/www"> #区域配置
AllowOverride None
# Allow open access: #注释信息
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
● httpd配置文件的查看
rpm -ql httpd #查看安装文件路径
rpm -qc httpd #查看配置文件名称
rpm
Apache服务器安装与配置指南

本文详细介绍了如何在Linux环境中安装Apache服务,并配置其默认设置,包括修改端口、设置默认发布文件和目录。此外,还讲解了Apache的虚拟主机配置,包括基于IP、端口和名称的虚拟主机配置。
最低0.47元/天 解锁文章
5万+

被折叠的 条评论
为什么被折叠?



