今天小編就為大家?guī)硪黄猘pache的虛擬web主機配置圖文介紹的文章。小編覺得挺不錯的,為此分享給大家做個參考。一起跟隨小編過來看看吧。
在下花園等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供成都網(wǎng)站設計、網(wǎng)站制作 網(wǎng)站設計制作定制網(wǎng)站建設,公司網(wǎng)站建設,企業(yè)網(wǎng)站建設,成都品牌網(wǎng)站建設,網(wǎng)絡營銷推廣,外貿(mào)網(wǎng)站建設,下花園網(wǎng)站建設費用合理。@[toc]
apache 常用的功能,虛擬主機
IP不同,端口相同
IP相同,端口不通
[root@localhost ~]# yum install bind httpd -y
Package 32:bind-9.11.4-9.P2.el7.x86_64 already installed and latest version
Package httpd-2.4.6-90.el7.centos.x86_64 already installed and latest version
Nothing to do
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]#
[root@localhost ~]# vim /etc/named.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; };
[root@localhost ~]# vim /etc/named.rfc1912.zones
zone "kgc.com" IN {
type master;
file "kgc.com.zone";
allow-update { none; };
};
zone "accp.com" IN {
type master;
file "accp.com.zone";
allow-update { none; };
};
[root@localhost ~]# cd /var/named/
[root@localhost named]# ls
data dynamic named.ca named.empty named.localhost named.loopback slaves
[root@localhost named]# cp -p named.localhost kgc.com.zone
[root@localhost named]# vim kgc.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.247.150
~
[root@localhost named]# cp -p kgc.com.zone accp.com.zone
[root@localhost named]# systemctl start named
[root@localhost httpd]# ls
conf conf.d conf.modules.d logs modules run
[root@localhost httpd]# ls -l
total 0
drwxr-xr-x. 2 root root 37 Dec 12 14:45 conf
drwxr-xr-x. 2 root root 82 Dec 12 14:45 conf.d
drwxr-xr-x. 2 root root 146 Dec 12 14:45 conf.modules.d
lrwxrwxrwx. 1 root root 19 Dec 12 14:45 logs -> ../../var/log/httpd
lrwxrwxrwx. 1 root root 29 Dec 12 14:45 modules -> ../../usr/lib64/httpd/modules
lrwxrwxrwx. 1 root root 10 Dec 12 14:45 run -> /run/httpd
[root@localhost httpd]#
[root@localhost httpd]# cd conf
[root@localhost conf]# ls
httpd.conf magic
[root@localhost conf]# mkdir extra
[root@localhost conf]# cd extra/
[root@localhost extra]# ls
[root@localhost extra]#
/etc/httpd/conf/extra/vhost.conf文件中
[root@localhost extra]# vim vhost.conf
1 <VirtualHost *:80>
2 DocumentRoot "/var/www/html/kgc"
3 ServerName www.kgc.com
4 Errorlog "logs/www.kgc.com.error_log"
5 Customlog "logs/www.kgc.comaccess_log" common
6 <Directory "/var/www/html">
7 Require all granted
8 </Directory>
9 </VirtualHost>
10
11 <VirtualHost *:80>
12 DocumentRoot "/var/www/html/accp"
13 ServerName www.accp.com
14 Errorlog "logs/www.accp.com.error_log"
15 Customlog "logs/www.accp.comaccess_log" common
16 <Directory "/var/www/html">
17 Require all granted
18 </Directory>
19 </VirtualHost>
### 2.1.5 創(chuàng)建兩個web站點的首頁,首頁文件index.html在/var/www/html下面的站點目錄中
```bash
[root@localhost extra]# cd /var/
[root@localhost var]# ls
account cache db games kerberos local log named opt run target www
adm crash empty gopher lib lock mail nis preserve spool tmp yp
[root@localhost var]# cd www
[root@localhost www]# ls
cgi-bin html
[root@localhost www]# cd html
[root@localhost html]# ls
[root@localhost html]# mkdir kgc accp
[root@localhost html]# ls
accp kgc
[root@localhost html]# echo "this is accp web" > accp/index.html
[root@localhost html]# echo "this is kgc web" > kgc/index.html
[root@localhost html]# tree accp kgc
accp
└── index.html
kgc
└── index.html
0 directories, 2 files
[root@localhost html]#
[root@localhost html]# vim /etc/httpd/conf/httpd.conf
354 Include conf/extra/vhost.conf
[root@localhost html]# systemctl start httpd
[root@localhost html]# netstat -natp | grep httpd
tcp6 0 0 :::80 :::* LISTEN 79262/httpd
[root@localhost html]# vim /etc/httpd/conf/extra/vhost.conf
//復制修改增加
11 <VirtualHost *:8080>
12 DocumentRoot "/var/www/html/kgc02"
13 ServerName www.kgc02.com
14 Errorlog "logs/www.kgc02.com.error_log"
15 Customlog "logs/www.kgc02.comaccess_log" common
16 <Directory "/var/www/html">
17 Require all granted
18 </Directory>
19 </VirtualHost>
[root@localhost html]# ls
accp kgc
[root@localhost html]# cp -p kgc kgc02
cp: omitting directory ‘kgc’
[root@localhost html]# mkdir kgc02
[root@localhost html]# echo "this is web kgc02" >kgc02/index.html
[root@localhost html]#
[root@localhost html]# vim /etc/httpd/conf/httpd.conf
41 Listen 192.168.247.150:80
42 Listen 192.168.247.150:8080
43 #Listen 80
[root@localhost html]# systemctl restart httpd
[root@localhost html]# netstat -napt | grep httpd
tcp 0 0 192.168.247.150:8080 0.0.0.0:* LISTEN 91814/httpd
tcp 0 0 192.168.247.150:80 0.0.0.0:* LISTEN 91814/httpd
[root@localhost html]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.247.150 netmask 255.255.255.0 broadcast 192.168.247.255
ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.247.158 netmask 255.255.255.0 broadcast 192.168.247.255
[root@localhost html]# vim /etc/httpd/conf/extra/vhost.conf
<VirtualHost 192.168.247.158:80>
DocumentRoot "/var/www/html/accpaccp"
ServerName www.accpaccp.com
Errorlog "logs/www.accpaccp.com.error_log"
Customlog "logs/www.accpaccp.comaccess_log" common
<Directory "/var/www/html">
Require all granted
</Directory>
</VirtualHost>
[root@localhost html]# ls
accp accp02 kgc kgc02
[root@localhost html]# mkdir accpaccp
[root@localhost html]# echo "this is 192.168.247.158" > accpaccp/index.html
[root@localhost html]# vim /etc/httpd/conf/httpd.conf
Listen 192.168.247.158:80
[root@localhost html]# systemctl restart httpd
[root@localhost html]# netstat -natp | grep httpd
tcp 0 0 192.168.247.150:8080 0.0.0.0:* LISTEN 123662/httpd
tcp 0 0 192.168.247.158:80 0.0.0.0:* LISTEN 123662/httpd
tcp 0 0 192.168.247.150:80 0.0.0.0:* LISTEN 123662/httpd
#####因為沒有配置dns解析,所以需要輸入IP地址去進入網(wǎng)站,接下來增加這個ip地址的域名解析
[root@localhost html]# vim /etc/named.rfc1912.zones
zone "accpaccp.com" IN {
type master;
file "accpaccp.com.zone";
allow-update { none; };
};
[root@localhost html]# cd /var/named
[root@localhost named]# ls
accp.com.zone data dynamic kgc.com.zone named.ca named.empty named.localhost named.loopback slaves
[root@localhost named]# cp -p accp.com.zone accpaccp.com.zone
[root@localhost named]# vim accpaccp.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.247.158
[root@localhost named]# systemctl restart named
[root@localhost named]# vim /var/www/html/accpaccp/index.html
<html>
<head>
<title>hello world</title>
</head>
<body>
<h2><a href="http://www.accp.com/index.html">hello world</a></h2>
</body>
</html>
[root@localhost named]# systemctl restart httpd
上述就是apache的虛擬web主機配置的詳細內(nèi)容,詳細使用情況還需要大家自己動手實驗使用過才能領(lǐng)會。如果想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
當前名稱:apache的虛擬web主機配置圖文介紹-創(chuàng)新互聯(lián)
文章來源:http://jinyejixie.com/article0/dhcsoo.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供手機網(wǎng)站建設、用戶體驗、網(wǎng)站維護、網(wǎng)頁設計公司、全網(wǎng)營銷推廣、域名注冊
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)