linux Apache服务管理

一、Apache 默认发布目录/文件

 1.配置yum源,安装http服务

 2.打开http,修改防火墙配置

  systemctl   start   httpd

  firewall-cmd   --permanent   --add-service=http

  firewall-cmd   --reload

 3.建立默认发布文件  /var/www/html/index.html

<h1>hello everyone</h1>       ##h1字体设置

  网页访问,可看到默认发布文件的内容

 

 4.修改默认发布文件(http 主配置文件:/etc/httpd/conf/httpd.conf

167 <IfModule  dir_module>

168     DirectoryIndex  test.html  index.html   ##优先级,谁在前先读谁,不存在的话就跳过

169 </IfModule>

 5.重启http服务,网页访问将看到test.html 的内容:

 6.修改默认发布目录

  mkdir   /hello/html   -p

  修改主配置文件  /etc/httpd/conf/httpd.conf

  重启httpd服务,网页访问将看到/hello/html/index.html内容

  #####注意selinux级别#####

  当selinux=disabled,重启http服务后可看到默认发布文件

  但是,当selinux=enforing,必须修改安全上下文才能看到默认发布文件

  semanage   fcontext  -a  -t   httpd_sys_content_t   '/hello(/.*)?'

  restorecon   -RvvF   /hello/

  ########################

二、Apache的虚拟主机设置

 1.还原http的默认配置

 2.建立虚拟主机的默认发布目录和文件

  mkdir   /var/www/virtual/news/html  -p

  mkdir   /var/www/virtual/music/html  -p

  vim  /var/www/virtual/music/html/index.html

  vim  /var/www/virtual/news/html/index.html

 

 3.配置默认、music和news的文件   ##目录/etc/httpd/conf.d/

[root@testdb conf.d]# cat   default.conf

<VirtualHost  _default_:80>

    DocumentRoot   /var/www/html           ##默认发布目录

    CustomLog  logs/default.log   combined  ##所有日志存放(访问,警告,拒绝,错误

</VirtualHost>

 4.重启http服务,在访问主机进行域名解析(/etc/hosts

 5.网页访问结果查看

  访问http://www.westos.com/结果:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值