实验:httpd

虚拟主机

httpd-2.4示例步骤:

1. 进行规划虚拟主机
192.168.209.8:80,192.168.209.10:80
www.10linux.com,www.iounix.com
/var/www/html/10linux,/var/www/html/iounix

2.
]# mkdir /var/www/html/{10linux,iounix}
~]# vim /var/www/html/iounix/index.html
    <h1>iounix.com</h1>
~]# vim /var/www/html/10linux/index.html
    <h1>10linux.com</h1>
    <h2>welcome here</h2>

3. 编辑配置文件
/etc/httpd/conf.d/10linux.conf
<VirtualHost 192.168.209.8:80>
        ServerName www.10linux.com
        DocumentRoot "/var/www/html/10linux"
        <Directory "/var/www/html/10linux">
                Options None
                AllowOverride None
                Require all granted
        </Directory>
        CustomLog "logs/10linux_access_log"
</VirtualHost>

/etc/httpd/conf.d/iounix.conf
<VirtualHost 192.168.209.10:80>
        ServerName www.iounix.com
        DocumentRoot "/var/www/html/iounix"
        <Directory "/var/www/html/iounix">
                Options None
                AllowOverride None
                Require all granted
        </Directory>
        CustomLog "logs/iounix_access_log" combined
</VirtualHost>

4.
httpd -t
systemctl restart httpd.service

5. 验证:不同IP,相同端口
    ip addr add 192.168.209.10/24 dev eth0
6. 验证:相同IP,不同端口
    需在配置文件中添加Listen 10080,修改IP地址; 使IP相同,port不同
    ip addr del 192.168.209.10/24 dev eth0

7. 验证:相同IP,相同端口,不同主机名
    可搭建DNS解析验证

问题:重启httpd服务Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

httpd内建的状态页面

httpd-2.4示例:

1
vim /etc/httpd/conf.d/10linux.conf
<VirtualHost 192.168.209.8:80>
        ServerName www.10linux.com
        DocumentRoot "/var/www/html/10linux"
        <Directory "/var/www/html/10linux">
                Options None
                AllowOverride None
                Require all granted
        </Directory>
        CustomLog "logs/10linux_access_log"
        <Location /server-status>
            SetHandler server-status
            <RequireAll>
                Require ip 172.16
            </RequireAll>
        </Location>    
</VirtualHost>

2
查看:www.10linux.com/server-status

3
如要做认证:
<Location /server-status>
    SetHandler server-status
    AuthType ...
    ...

</Location>

原创文章,作者:s,如若转载,请注明出处:http://www.178linux.com/77502

赞 (0)
ss
上一篇 2017-06-04 21:33
下一篇 2017-06-04 21:41

相关推荐

  • 网络配置、nmcli

    CentOS 7 网络属性配置    rhel6 之前,网络接口使用连续号码命名:eth0 、eth1 等, 当增加或删除网卡时,名称可能会 发生变化    rhel7 使用基于硬件,设备拓扑和设置类型 命名:    (1) 网卡命名机制    &n…

    Linux干货 2016-09-23
  • CentOS 5,6 系统启动流程详解

        一、linux 组成介绍          1.linux 组成:              Lin…

    Linux干货 2016-09-11
  • Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示

    目录与路径 相对路径与绝对路径 绝对路径:路径的写法【一定由根目录 / 写起】 /usr/share/doc 这个目录。 相对路径:路径的写法【不是由 / 写起】 由 /usr/share/doc 要到 /usr/share/man 底下时,可以写成: 【cd ../man】这就是相对路径的写法。相对路径意指相对于当前的工作目录 cd (切换目录) . &n…

    Linux干货 2016-11-06
  • LAMP+logzilla+sphinx+syslog-ng实现集中日志管理(第一版)[原创]

    一、前言        目前查看系统日志比较被动,遇到系统不正常或故障时才会主动去检查服务器系统日志,这样一来不能及时了解系统的运行情况,因此部署Logzilla+sphine+syslog-ng来弥补这不足。以下为安装、部署平台详细步骤。(Logzilla是什么新东西?其实前身就是php-syslog-ng,引用作者…

    Linux干货 2015-03-27
  • iptables/netfilter进阶

      在上一章当中我们介绍了iptables的介绍以及它的基本使用,下面我们开始介绍iptables的命令用法以及iptables是如何工作的。 1、回顾 2、iptables相关命令 1、回顾   我们回顾一下上一章节的内容,在上一章节中我们讲述的是iptables的基本概念以及命令格式,同时讲述规则链与表的概念,那么…

    Linux干货 2017-02-03
  • 第二周博客作业

    一、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示 Linux文件管理类命令有cp、mv、rm 1、cp命令:copy files and directories 使用方法: 单源复制cp [OPTION]… [-T] SOURCE DEST1)如果DEST不存在,则事先创建此文件,并复制源文件的数据流至DEST中2)如果…

    Linux干货 2016-12-13