您好,登錄后才能下訂單哦!
一、Apache
? (1)基于訪問主機頭(FQDN)
cat?/etc/httpd/conf.d/vhostfqdn.conf? <virtualhost?*:80> documentroot?/data/web01 servername?www.web01.com <directory?/data/web01> require?all?granted </directory> CustomLog?"logs/a_access_log"?combined </virtualhost> <virtualhost?*:80> documentroot?/data/web02 servername?www.web02.com <directory?/data/web02> require?all?granted </directory> CustomLog?"logs/a_access_log"?combined </virtualhost> <virtualhost?*:80> documentroot?/data/web03 servername?www.web03.com <directory?/data/web03> require?all?granted </directory> CustomLog?"logs/a_access_log"?combined </virtualhost>
(2)基于ip地址
cat?/etc/httpd/conf.d/vhostip.conf? <virtualhost?192.168.130.11:80> documentroot?/data/web01 <directory?/data/web01> require?all?granted </directory> </virtualhost> <virtualhost?192.168.130.22:80> documentroot?/data/web02 <directory?/data/web02> require?all?granted </directory> </virtualhost> <virtualhost?192.168.130.33:80> documentroot?/data/web03 <directory?/data/web03> require?all?granted </directory> </virtualhost>
(3)基于端口號
cat??/etc/httpd/conf.d/vhostport.conf? listen?8001 listen?8002 listen?8003 <virtualhost?*:8001> documentroot?/data/web01 <directory?/data/web01> require?all?granted </directory> </virtualhost> <virtualhost?*:8002> documentroot?/data/web02 <directory?/data/web02> ????? require?all?granted </directory> </virtualhost> <virtualhost?*:8003> documentroot?/data/web03 <directory?/data/web03> require?all?granted </directory> </virtualhost>
二、Nginx
(1)基于域名且不同站點
?server?{ ?????????listen???????80; ?????????server_name??mobile.magedu.com; ?????????location?/?{ ?????????????root???html; ?????????????index??index.html?index.htm; ?????????} ?????????location?/python?{ ?????????????root???/mobile;????????!!!必須在/mobile目錄下創建/python目錄,且把文件寫入python目錄中,否則會報錯!!! ?????????????index??index.html?index.htm; ?????????} ?????????location?/java?{ ?????????????root???/mobile; ?????????????index??index.html?index.htm; ?????????} ?????} ?server?{ ?????????listen???????80; ?????????server_name??www.magedu.com; ?????????location?/?{ ?????????????root???html; ?????????????index??index.html?index.htm; ?????????} ?????????location?/python?{ ?????????????root???/www; ?????????????index??index.html?index.htm; ?????????} ?????????location?/java?{ ?????????????root???/www; ?????????????index??index.html?index.htm; ?????????} ?????}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。