Apache 2.5 配置虛擬機器主機

來源:互聯網
上載者:User

標籤:參數   link   system   yml   localhost   src   option   表示   extra   

1、在 Apache 的安裝目錄下 conf/httpd.conf 檔案中搜尋 hosts,去掉前面的“#”號,即可啟用虛擬機器主機。

 

2、然後在 Apache 的安裝目錄下 conf/extra 裡面找到 httpd-vhosts.conf 檔案。

    這裡以 larablog.com 為例,配置如下。詳細參數見最後說明。

#配置larablog.com:80<VirtualHost *:80>  #主機名稱  ServerName larablog.com  #主目錄  DocumentRoot "D:/wamp/www/laravel/larablog/public/"  #根目錄許可權  <Directory "D:/wamp/www/laravel/larablog/public/">    Options Indexes FollowSymLinks    AllowOverride All    Require local  </Directory>  #錯誤記錄檔儲存位置  ErrorLog "logs/dummy-host.example.com-error.log"  CustomLog "logs/dummy-host.example.com-access.log" common</VirtualHost>

 

3、最後在 C:\WINDOWS\system32\drivers\etc\hosts 檔案的最末尾添加 DNS 解析。

127.0.0.1        larablog.com

 

4、儲存修改,重啟 Apache 伺服器。在瀏覽器地址欄鍵入 larablog.com 就可以訪問了。

 

說明:Apache 的一些配置參數

# 目錄存取權限設定<Directory "D:/wamp/www/">
# Options 該指令控制目錄啟用哪些伺服器特性。常見的特性有以下幾個,多個特性空格隔開。 # Indexes 指示如果訪問的該目錄沒有 index.html 檔案,就列出檔案夾下的檔案和子檔案夾。 # FollowSymLinks 載入符號串連 # Multiviews 啟用多重視圖。訪問 http://localhost/file/hello,在沒有 hello 檔案夾時,將通配 hello.* 檔案並根據環境返回一個。 Options Indexes FollowSymLinks # AllowOverride 是否允許覆蓋。安全起見建議為 None。在使用架構時可能會用到URL rewrite,就要設定允許 All AllowOverride All
# Require 授權訪問。all granted 允許所有使用者, local 允許本機使用者。 Require all granted
</Directory>

 

此外,Options 指令允許在配置選項前加上符號"+"或者"-",表示“啟用”或者“移除”特性。

 

有關Options 指令的更多特性,參考這裡:Apache Options 指令詳解

Apache 2.5 配置虛擬機器主機

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.