3、Apache Server安装&配置(CentOS7)

一、前言

  • 前置知识?
  1. vi命令:用来编辑文件;https://www.cnblogs.com/88999660/articles/1581524.html
  2. 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

三、Web应用/站点配置

  • 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值