Virtual Host配置過程
這里例子中我們的路徑為這樣
DocumentRoot: /home/jb51 /sites/demo.Vevb.com
ServerName:demo.Vevb.com
1.進入apache虛擬主機設置目錄
cd /etc/apache2/sites-available
2.創建文件demo.Vevb.com
<VirtualHost *:80> ServerAdmin webmaster@localhost DirectoryIndex index.html index.php DocumentRoot /home/jb51 /sites/demo.Vevb.com ServerName demo.Vevb.com ServerAlias demo.Vevb.com <Directory "/home/jb51 /sites/demo.Vevb.com"> allow from all Options + Indexes </Directory> </VirtualHost>
3.激活虛擬主機配置
sudo a2ensite demo.Vevb.com
4.進入 /etc/apache2/sites-enabled/目錄,可以查看所有激活的虛擬主機。可以用 sudo a2dissite demo.Vevb.com 注銷
cd /etc/apache2/sites-enabled ls -lt
顯示
代碼如下:
lrwxrwxrwx 1 root root 36 2013-04-05 17:29 demo.Vevb.com -> ../sites-available/demo.Vevb.com
5.重啟apache服務
sudo /etc/init.d/apache2 restart
6.ubuntu 設置host
vim /etc/hosts
127.0.0.1 demo.Vevb.com
7.<Directory>設置開啟.htaccess與顯示目錄結構列表
<Directory "/home/jb51 /demo.Vevb.com"> AllowOverride none AllowOverride all Options -Indexes FollowSymLinks </Directory>
AllowOverride none 表示關閉.htaccess,如要開啟可設置為AllowOverride all
Options -Indexes 表示關閉目錄結構顯示,如要開啟可設置為 Options Indexes
Options FollowSymLinks 表示支持symbol link(軟連接),如要關閉可設置為Options -FollowSymLinks
rewrite模塊重要參數說明
開啟rewrite:
sudo a2enmod rewrite
停用rewrite:
sudo a2dismod rewrite
服務器環境變量:Apache提供給rewirte模塊的環境變量大概分成5個類型.
第一部分: HTTP headers 部分參數
1.參數名稱: HTTP_USER_AGENT
樣例參考值: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8
說明: 相當于PHP中的服務器參數: $_SERVER["HTTP_USER_AGENT"]
2.參數名稱: HTTP_REFERER
樣例參考值: http://www.test.cn/test.php
說明: 相當于PHP中的服務器參數: _SERVER["HTTP_REFERER"]
3.參數名稱: HTTP_COOKIE
樣例參考值: ZDEDebuggerPresent=php,phtml,php3
說明: 相當于PHP中的服務器參數: $_SERVER["HTTP_COOKIE"]
4.參數名稱: HTTP_FORWARDED
樣例參考值: 如果使用代理服務器的話會是代理服務器的IP地址, 本地不容易搭環境測試出值來.
新聞熱點
疑難解答