伺服器-Name-based Virtual Host
將/etc/httpd/conf/httpd.conf的VirtualHost相關設定移動/etc/httpd/conf.d/vhost.conf 編輯 Apache 組態檔
# vim /etc/httpd/conf.d/vhost.conf
NameVirtualHost *:80
<VirtualHost *:80> // 此區塊設定可以省略
DocumentRoot /var/www/html
ServerName apacheserver139.example.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/vhost
ServerName vhostapacheserver139.example.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/svhost
ServerName secretapacheserver139.example.com
<Directory /var/www/svhost>
AuthName "Secret Hideout"
AuthType basic // 傳輸過程不加密,因此最好搭配 ssl 才安全。
AuthUserFile /var/www/svhost/users
require valid-user
</Directory>
</VirtualHost>
重啟 Apache
# service httpd restart
沒有留言:
張貼留言