文章目录
一、Apache的作用
- 在web被访问时通常使用 http://(超文本传输协议) 的方式
- http//超文本传输协议提供的软件:Apache、nginx、stgw、jfe、Tengine
二、Apache的安装
三、Apache的启用
- 开启服务并设定服务位开机启动:systemctl enable --now httpd
- 查看火墙信息:firewall-cmd --list-all
- 在火墙中永久开启http访问:firewall-cmd --permanent --add-service=http
- 在火墙中永久开启https访问:firewall-cmd --permanent --add-service=https
- 刷新火墙使设定生效:firewall-cmd --reload
四、Apache的基本信息
- 服务名称:httpd
- 配置文件:主配置文件:/etc/httpd/conf/httpd.conf;子配置文件:/etc/httpd/conf.d/*.conf
- 默认发布目录:/var/www/html
- 默认发布文件:index.html
- 默认端口:80(http);443(https)
- 用户:apache
- 日志:/etc/httpd/logs
五、Apache的基本配置
编辑主配置文件:/etc/httpd/conf/httpd.conf
1. Apache端口修改
(1)设定端口:在(不在)允许端口列表
(2)设定火墙允许端口:firewall-cmd --permanent --add-port=8080(6666)/tcp
(3)刷新火墙使设定生效:firewall-cmd --reload
当设定的端口不在允许端口列表时多两步操作:
(4)添加端口到允许列表:semanage port -a -t http_port_t -p tcp 6666
(5)重启服务:systemctl restart httpd
列出服务可以使用的端口列表:semanage port -l | grep http
1. 当更改端口为允许列表的端口时: