1、Apache基於網域名稱虛擬機器主機
<VirtualHost *:80>DocumentRoot 路徑ServerName 網域名稱ServerAlias ucenter.comErrorLog "/logs/網域名稱-error_log"CustomLog "/logs/網域名稱-access_log"</VirtualHost><Directory "路徑"> Options FollowSymLinks AllowOverride None Order deny,allow Allow from all</Directory>
2、Apache基於連接埠虛擬機器主機
listen 8081<VirtualHost *:8081> DocumentRoot "/test" ServerName 192.168.0.200 <Directory "/test/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order Deny,Allow Allow from all</Directory></VirtualHost>
3、Apache虛擬目錄:
Alias /虛擬目錄名/ "/myweb"<Directory "/myweb">Options Indexes MultiViewsAllowOverride NoneOrder allow,denyAllow from all</Directory>
4、HTTP使用者認證訪問
<VirtualHost *:80>DocumentRoot /var/www/html<Directory "/var/www/html"> authtype basic authname "Please input Password" #提示資訊 authuserfile /etc/httpd/.passwd #認證檔案路徑.passwd未隱藏檔案 require user user1 #使用者必須輸入密碼訪問</Directory></VirtualHost>htpasswd -cm /etc/httpd/.passwd user1 #此處密碼與使用者的系統密碼無關service httpd restart
5、Nginx虛擬機器主機
vi /usr/local/nginx/conf/nginx.conf #載入虛擬機器主機配置include vhost/*.conf;vi /usr/local/nginx/conf/vhost #建立虛擬機器主機設定檔server {listen 80;server_name www.test.com;index index.html index.htm index.php;root /var/www/test.com;access_log /var/log/test.com.log test.com;}service nginx restart #重啟服務
6、Tomcat虛擬機器主機
tomcat/conf/server.xml添加:<Host name="www.test.com" appBase="/web" unpackWARs="true" autoDeploy="true"xmlValidation="false" xmlNamespaceAware="false"><Context path="/" (虛擬目錄名)docBase=""虛擬目錄路徑) debug=”0” /></Host>
本文出自 “Linux熱門技術” 部落格,請務必保留此出處http://going.blog.51cto.com/7876557/1294258