4.Virtual Host (網站代管)
(1)建立目錄
#mkdir -p /var/www/html/virt1
#mkdir -p /var/www/html/virt2
並在virt1, virt2裡建立index.html檔案, 當然別忘了SElinux: #restorecon -R /var/www/html
(2)確認DNS是否正確, 增加DNS的A紀錄
[root@server118 ~]# dig virt1.example.com
; <<>> DiG 9.3.4-P1 <<>> virt1.example.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20486
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;virt1.example.com. IN A
;; ANSWER SECTION:
virt1.example.com. 86400 IN A 192.168.0.118
;; AUTHORITY SECTION:
example.com. 86400 IN NS server1.
;; Query time: 4 msec
;; SERVER: 192.168.0.254#53(192.168.0.254)
;; WHEN: Sat Aug 1 10:54:05 2009
;; MSG SIZE rcvd: 72
[root@server118 ~]# dig virt2.example.com
; <<>> DiG 9.3.4-P1 <<>> virt2.example.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64303
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;virt2.example.com. IN A
;; ANSWER SECTION:
virt2.example.com. 86400 IN A 192.168.0.118
;; AUTHORITY SECTION:
example.com. 86400 IN NS server1.
;; Query time: 4 msec
;; SERVER: 192.168.0.254#53(192.168.0.254)
;; WHEN: Sat Aug 1 10:54:11 2009
;; MSG SIZE rcvd: 72
(3) #vi /etc/httpd/conf/httpd.conf
#vi /etc/httpd/conf/httpd.conf
---略---
NameVirtualHost 192.168.0.118:80
ServerAdmin student@virt1.example.com
DocumentRoot /var/www/html/virt1
ServerName virt1.example.com
ErrorLog logs/virt1.example.com-error_log
CustomLog logs/virt1.example.com-access_log common
ServerAdmin student@virt2.example.com
DocumentRoot /var/www/html/virt2
ServerName virt2.example.com
ErrorLog logs/virt2.example.com-error_log
CustomLog logs/virt2.example.com-access_log common
%也可以寫在/etc/httpd/conf.d/virtual_host.conf (名字自己取)
%這麼多設定那背的起來, 當然找 httpd.conf 複製啦 (keword: NameVirtualHost)
%再來修改設定囉
(4)重新啟動
#service httpd restat
http://virt1.example.com
http://virt2.example.com
%虛擬網站啟動後, http://server118.example.com會被取代,無法看到
%個人網頁putlic_html, http://server118.example.com/student , 也無法看到
%但是http://server118.example.com/~student, 卻可以看到喔
Previous post in this category: [雜記]RHCE筆記整理-RH253-Unit7(3)
Next post in this category: [雜記]RHCE筆記整理-RH253-Unit7(5)
學習(2)
[雜記]RHCE筆記整理-考試綱要(2)
Recommend to Front page
Comment Permissions: Only members may comment. If you are not a PIXNET member, click here to sign up.