實驗: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.www58058.com/77502

(0)
ss
上一篇 2017-06-04
下一篇 2017-06-04

相關推薦

  • 有趣的bash腳本

    1、編寫腳本/root/bin/createuser.sh,實現如下功能:使 用一個用戶名做為參數,如果指定參數的用戶存在,就顯示 其存在,否則添加之;顯示添加的用戶的id號等信息 #!/bin/bash read -p “Please input username: ” n if id $n &> /dev/null;then echo “T…

    Linux干貨 2017-08-25
  • 淺談Linux中的用戶和組

    又到了周六,日常寫博客的日子。 上周模模糊糊的寫了第一篇博客,大概知道了怎么寫,但是這周就比以往不同了,腦子中已經有了思路,那寫起來就會更加詳細易懂。 這周學了很多知識點,但是我想對Linux 用戶和組進行詳細的描述。 一、用戶(Username/UID) 用戶分為兩種:管理員和普通用戶     管理員root  UI…

    2017-07-22
  • 馬哥教育Net20第二十二天:在Centos7上實現lmnp

    要求: vhost1: pma.stuX.com, phpMyAdmin, 同時提供https服務; vhost2: wp.stuX.com, wordpress vhost3: dz.stuX.com, Discuz  環境說明: DNS是:192.168.100.7 vhos…

    Linux干貨 2016-07-02
  • linux中更改文件權限的實驗

      三種基本權限    r 讀 數值表示為4 w寫 數值表示為2 X 可執行數值表示為1              簡單舉例: -rw-rw-r–共十個字符,分成四段 第一個字符“-”表示普通文件;這個位置還可能會出現“l”鏈接;“d”表示目錄 第…

    2017-07-15
  • N25-第5周作業

    1、顯示/boot/grub/grub.conf中以至少一個空白字符開頭的行 [root@jizo ~]# grep -E '^[[:space:]]+.*' /boot/grub/gurb.conf 2、顯示/etc/rc.d/rc.sysinit文件中以#開頭,后面跟至少一個空白字符,…

    Linux干貨 2017-01-09
  • Bash Shell之數組簡介

    Bash Shell之數組簡介   一、數組基本概念   數組是內存中的存儲空間,連續的多個存儲單元;bash中只支持一維數組,支持稀疏格式 ,參數個數沒有限制。 二、數組基本語法格式   1、聲明一個數組          declare…

    Linux干貨 2015-05-11
欧美性久久久久