一、前言
- 前置知识?
- vi命令:用来编辑文件;https://www.cnblogs.com/88999660/articles/1581524.html
- systemctl命令:服务操作;https://ken.io/note/centos-quickstart-basiccommand
- 1、 安装
yum install httpd
- 2、 设置为开机启动&启用
systemctl enable httpd && systemctl start httpd
- 3、 防火墙端口开放
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload
- 4、访问
http://ip
#/usr/share/httpd/noindex/index.html
- 1、新建站点目录&index页面
#创建站点根目录
mkdir /var/www/web
#进入站点根目录并创建index.html
cd /var/www/web && vi index.html
#写入hello并保存即可,方便后续测试使用
- 2、创建站点配置目录
mkdir /etc/httpd/sites
- 3、修改默认配置
vi /etc/httpd/conf/httpd.conf
#增加项:
IncludeOptional /etc/httpd/sites/*.conf
- 4、新建站点配置
vi /etc/httpd/sites/default.conf
#配置内容
<VirtualHost *:80>
ServerName hello.html.com
ServerAlias html.com
DocumentRoot /var/www/web/
ErrorLog /var/www/web/error.log
CustomLog /var/www/web/requests.log combined
</VirtualHost>
- 5、访问测试
本地修改hosts文件,把hello.html.com指向该CentOS服务器IP,然后通过该域名访问即可。
http://hello.html.com
- 6、端口使用注意事项
1、虚拟机绑定的端口一定是Apache监听的端口
2、建议Apache使用81端口把80端口让给Nginx
- 相关阅读
Windows系统修改hosts文件:https://jingyan.baidu.com/article/b907e627d86be046e6891c41.html
本文详细介绍了在CentOS系统中安装Apache Web服务器的方法,包括安装、设置开机启动、防火墙端口开放及访问配置。此外,还深入讲解了如何进行Web应用或站点的配置,如创建站点目录、修改默认配置、新建站点配置等步骤,以及在测试过程中需要注意的事项。

6万+

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



