日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Apaceh配置httpd-vhosts虚拟主机

發布時間:2025/3/15 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Apaceh配置httpd-vhosts虚拟主机 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

經常使用Apache虛擬主機進行開發和測試,但每次需要配置虛擬主機時都習慣性的ctrl+c和ctrl+v,這次由于重裝系統,需要配置一個新的PHP開發環境虛擬主機,于是總結一下Apaceh配置httpd-vhosts虛擬主機使用方法和步驟,便于查找和使用。

開發環境:WAMP
網址:http://www.wampserver.com/en/

實例一,Apaceh配置localhost虛擬主機步驟
1,用記事本打開apache目錄下httpd文件(如:D:\wamp\bin\apache\apache2.2.8\conf),找到如下模塊

# Virtual hosts #Include conf/extra/httpd-vhosts.conf

去掉前面的#,這樣就開啟了httpd-vhosts虛擬主機文件。這時候重啟wamp環境,無法打開localhost,需要在httpd-vhosts.conf配置一下。

2,用記事本打開httpd-vhosts文件,配置好localhost虛擬主機,參照httpd-vhosts文件中實例,修改成如下:

<VirtualHost *:80> ServerAdmin webmaster@dummy-host.localhost DocumentRoot "D:\wamp\www" ServerName localhost ServerAlias localhost ErrorLog "logs/dummy-host.localhost-error.log" CustomLog "logs/dummy-host.localhost-access.log" common </VirtualHost>

修改配置如下:
DocumentRoot 修改為本地wamp環境下的www目錄(如:D:\wamp\www)
ServerName改為localhost

3,重啟Apache,發現localhost可以正常打開,配置localhost比較簡單。

實例二,Apaceh配置test.biuuu.com虛擬主機步驟

1,方法同上,復制配置代碼修改如下:

<VirtualHost *:80> ServerAdmin test@biuuu.com DocumentRoot E:\WebRoot\biuuu ServerName test.biuuu.com ErrorLog "logs/dummy-host2.localhost-error.log" CustomLog "logs/dummy-host2.localhost-access.log" common </VirtualHost>

2,打開host文件(C:\WINDOWS\system32\drivers\etc\hosts),增加一行代碼

127.0.0.1 test.biuuu.com

3,在瀏覽器中打開test.biuuu.com,發現如下錯誤403 Forbidden錯誤
Forbidden
You don’t have permission to access / on this server.

分析:這主要是目錄訪問權限沒有設置,需要設置對目錄的訪問權!

4,打開httpd文件,找到如下語句

<Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory>

復制以上代碼,并進行目錄修改,把/替換為E:\WebRoot\biuuu,修改virtualHost代碼如下

<VirtualHost *:80> ServerAdmin test@biuuu.com DocumentRoot E:\WebRoot\biuuu ServerName test.biuuu.com ErrorLog "logs/dummy-host2.localhost-error.log" CustomLog "logs/dummy-host2.localhost-access.log" common <Directory E:\WebRoot\biuuu> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> </VirtualHost>

在瀏覽器中測試發現還是打不開,提示如上403 Forbidden錯誤,修改其中的Deny from all為allow from all

5,重啟Apache,虛擬主機配置成功!

注意事項
1,目錄路徑,如E:\WebRoot\biuuu
2,訪問權限,如上Deny from all修改為allow from all
3,host文件,配置虛擬域名host指向
4,httpd文件,打開Include conf/extra/httpd-vhosts.conf模塊
5,httpd-vhosts文件,配置虛擬主機

使用Apaceh配置httpd-vhosts虛擬主機對于開發人員來說比較簡單,但卻非常重要,僅供參考!

參考資料:

http://httpd.apache.org/docs/2.2/vhosts/

http://httpd.apache.org/docs/2.0/vhosts/examples.html

原創文章如轉載,請注明:轉載自 必優博客 http://www.biuuu.com/

顧銀鑫 注:如發生Fatal error: Allowed memory size of 8388608 bytes exhausted錯誤

修改php.ini設置memory_limit = 12M(默認8M)

或只需要在你的程序頭部加入: ini_set(“memory_limit”,”12M”);

總結

以上是生活随笔為你收集整理的Apaceh配置httpd-vhosts虚拟主机的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。