激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Linux|Centos|Ubuntu|系統進程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務器之家 - 服務器系統 - Centos - CentOS7配置httpd虛擬主機教程

CentOS7配置httpd虛擬主機教程

2022-01-20 17:52Vathe Centos

這篇文章主要為大家詳細介紹了CentOS7配置httpd虛擬主機教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本實驗旨在centos7系統中,httpd-2.4配置兩臺虛擬主機,主要有以下要求:

(1) 提供兩個基于名稱的虛擬主機:

  www1.stux.com,頁面文件目錄為/web/vhosts/www1;錯誤日志為/var/log/httpd/www1/error_log,訪問日志為/var/log/httpd/www1/access_log;
  www2.stux.com,頁面文件目錄為/web/vhosts/www2;錯誤日志為/var/log/httpd/www2/error_log,訪問日志為/var/log/httpd/www2/access_log;

(2) 通過www1.stux.com/server-status輸出其狀態信息,且要求只允許提供賬號的用戶訪問;

(3) www1不允許192.168.1.0/24網絡中的主機訪問; 

查看系統版本和httpd版本

?
1
2
3
4
5
[root@host ~]$httpd -v
server version: apache/2.4.6 (centos)
server built:  nov 14 2016 18:04:44
[root@host ~]$cat /etc/centos-release
centos linux release 7.3.1611 (core)

啟動httpd,測試能否正常運行

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@host ~]$systemctl start httpd.service
[root@host ~]$systemctl status httpd.service
● httpd.service - the apache http server
  loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
  active: active (running) since thu 2017-06-01 03:03:12 cst; 5s ago           #  active 表示正常運行
   docs: man:httpd(8)
      man:apachectl(8)
 process: 6473 execstop=/bin/kill -winch ${mainpid} (code=exited, status=0/success)
 main pid: 6485 (httpd)
  status: "processing requests..."
  cgroup: /system.slice/httpd.service
      ├─6485 /usr/sbin/httpd -dforeground
      ├─6486 /usr/sbin/httpd -dforeground
      ├─6487 /usr/sbin/httpd -dforeground
      ├─6489 /usr/sbin/httpd -dforeground
      ├─6490 /usr/sbin/httpd -dforeground
      └─6572 /usr/sbin/httpd -dforeground
 
jun 01 03:03:11 host systemd[1]: starting the apache http server...
jun 01 03:03:12 host systemd[1]: started the apache http server.

使用curl命令訪問

?
1
2
3
4
5
6
7
8
9
10
11
12
[root@host ~]$ip a show ens38  # 查看ip
3: ens38: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up qlen 1000
  link/ether 00:0c:29:dc:18:5f brd ff:ff:ff:ff:ff:ff
  inet 192.168.55.128/24 brd 192.168.55.255 scope global dynamic ens38
    valid_lft 1752sec preferred_lft 1752sec
  inet6 fe80::20c:29ff:fedc:185f/64 scope link
    valid_lft forever preferred_lft forever
[root@host ~]$curl http://192.168.55.128    # 訪問
<!doctype>
<h1>
  centos 7.3
</h1>

創建指定文件目錄

?
1
2
3
4
[root@host conf.d]$mkdir -pv /web/vhosts/www1
[root@host conf.d]$mkdir -pv /web/vhosts/www2
[root@host conf.d]$mkdir -pv /var/log/httpd/www2
[root@host conf.d]$mkdir -pv /var/log/httpd/www1

根據要求填寫虛擬主機配置信息

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# path /etc/httpd/conf.d/vir.conf   # 配置文件全路徑
#virtual host 1    # 虛擬主機1的配置
<virtualhost 192.168.55.128:80>
  errorlog "/var/log/httpd/www1/error_log"
  customlog "/var/log/httpd/www1/access_log" combined
  <location /server-status>
    sethandler server-status
  </location>
  <directory /web/vhosts/www1>
    <requireall>
    require all granted
    require not ip 192.168.1
    </requireall>
  </directory>
</virtualhost>
# virtual host 2   # 虛擬主機2的配置
<virtualhost 192.168.55.128:80>
  servername www2.stux.com
  documentroot "/web/vhosts/www2"
  errorlog "/var/log/httpd/www2/error_log"
  customlog "/var/log/httpd/www2/access_log" combined
  <directory /web/vhosts/www2>
    <requireall>
      require all granted
    </requireall>
  </directory>
</virtualhost>

創建www1和www2的index頁面

?
1
2
3
4
5
6
[root@host conf.d]$cat /web/vhosts/www1/index.html
welcome to www1
thank you
[root@host conf.d]$cat /web/vhosts/www2/index.html
welcome to www2
thank you

重載httpd配置文件

?
1
2
3
[root@host conf.d]$httpd -t
syntax ok
[root@host conf.d]$systemctl reload httpd.service

 修改客戶端主機的hosts文件,以便能解析域名

hosts在windows環境下的路徑為c:\windows\system32\drivers\etc。在該文件中添加兩行

192.168.55.128 www1.stux.com
192.168.55.128 www2.stux.com

訪問結果

CentOS7配置httpd虛擬主機教程

圖1、訪問www1站點

CentOS7配置httpd虛擬主機教程

圖2、訪問www2站點

CentOS7配置httpd虛擬主機教程

圖3、查看www1站點的訪問狀態——正常

CentOS7配置httpd虛擬主機教程

圖4、查看www2站點的訪問狀態錯誤

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

延伸 · 閱讀

精彩推薦
  • CentosCentOS 6.6實現永久修改DNS地址的方法

    CentOS 6.6實現永久修改DNS地址的方法

    這篇文章主要介紹了CentOS 6.6實現永久修改DNS地址的方法,涉及針對CentOS配置文件的相關設置技巧,具有一定參考借鑒價值,需要的朋友可以參考下 ...

    Linux社區4472020-08-21
  • CentosCentOS7設置日期和時間方法以及基本概念介紹

    CentOS7設置日期和時間方法以及基本概念介紹

    這篇文章主要介紹了CentOS7設置日期和時間方法以及基本概念介紹,本文講解使用CentOS7中的新命令timedatectl設置日期時間方法,需要的朋友可以參考下 ...

    CentOS之家6522019-09-19
  • CentosCentOS下Uptime命令詳解

    CentOS下Uptime命令詳解

    在Linux下,我們可以使用uptime命令,而且此命令不必使用root權限。uptime命令在系統中已經默認安裝了。今天小編為大家帶來的是CentOS下Uptime命令詳解;希望...

    CentOS之家11482019-06-19
  • CentosCentos 7開啟網卡自動獲取IP的詳細方法

    Centos 7開啟網卡自動獲取IP的詳細方法

    本篇文章主要介紹了Centos 7開啟網卡自動獲取IP的詳細方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧...

    凌鋒8972021-12-29
  • Centoscentos 安裝與操作方法

    centos 安裝與操作方法

    這篇文章主要介紹了centos 安裝與操作方法,需要的朋友可以參考下...

    centos之家5272019-07-11
  • CentosCentos7運用/dev/shm進行網站優化

    Centos7運用/dev/shm進行網站優化

    這篇文章主要介紹了LINUX中Centos7運用/dev/shm進行網站優化相關知識點,對此有興趣的朋友參考學習下。...

    彬菌9912022-03-02
  • Centoscentos不小心刪除/root目錄該如何解決?

    centos不小心刪除/root目錄該如何解決?

    一些朋友最近在問小編centos不小心刪除/root目錄該如何解決?今天小編就為大家分享centos不小心刪除/root目錄解決辦法;希望對大家會有幫助,有需要的朋友...

    腳本之家8022019-05-29
  • CentosCentOS6.5下Redis安裝與配置詳細步驟

    CentOS6.5下Redis安裝與配置詳細步驟

    本篇文章主要介紹了CentOS6.5下Redis安裝與配置詳細步驟,詳細介紹redis單機單實例安裝與配置,服務及開機自啟動。有興趣的可以了解一下。...

    飛流11452021-12-24
主站蜘蛛池模板: 91午夜在线观看 | 视频一区二区国产 | 特黄一级小说 | 成人免费一区二区三区 | teensexhd| 久久经典免费视频 | 色妹子久久 | 免费a级黄色片 | 99seav | 成年人免费黄色片 | 欧美精品一区二区免费 | 中文字幕欧美一区二区三区 | 99在线热视频 | 91看片王| 久久av一区二区 | 神马福利网| 日韩精品一区二区免费视频 | 毛片网站网址 | 亚欧在线免费观看 | 国产免费一区二区三区网站免费 | 日本在线观看高清完整版 | 天堂福利电影 | 成人免费激情视频 | 91av在线影院 | 一级黄色在线免费观看 | 国产午夜精品久久久久久免费视 | 男女无套免费视频 | 天天夜夜操操 | 狠狠操天天射 | 久久99精品久久久久久小说 | 久久精品视频黄色 | 韩国精品一区二区三区四区五区 | 国产精品久久久久久久久久东京 | 牛牛视频在线 | 成人黄色免费电影 | 日韩在线欧美在线 | 久久99精品久久久久久园产越南 | 毛片电影在线看 | 国产精选久久久 | 久久99精品久久久久久园产越南 | 午夜精品在线视频 |