安裝Apache配置虛擬目錄
阿新 • • 發佈:2017-10-09
apache2.2 vhosts 服務器 apache服務 files from onf all apache
首先在apache的安裝目錄下找到conf目錄下找到httpd.conf文件
然後搜索hosts找到 把前面的井號去掉即可啟動虛擬主機
2、然後在apache的安裝目錄下找到conf目錄下的extra找到httpd-vhosts.conf文件
- #配置我們自己的虛擬主機
- <VirtualHost *:80>
- #修改文檔根路徑
- DocumentRoot "D:/Program Files (x86)/myenv/apache2.2.25/htdocs"
- #主機名稱
- ServerName myvirtualhost.com
- #歡迎頁面
- DirectoryIndex index.html
- <Directory "D:/Program Files (x86)/myenv/apache2.2.25/htdocs">
- Options -Indexes FollowSymLinks
- AllowOverride None
- Order allow,deny
- Allow from all
- </Directory>
- #錯誤日誌存放位置
- ErrorLog "logs/myvirtualhost.com-error.log"
- CustomLog "logs/myvirtualhost.com-access.log" common
- </VirtualHost>
-
在host文件中添加虛擬主機 高亮部分
- 二、apache虛擬目錄的配置
1、首先在apache的安裝目錄下找到conf目錄下找到httpd.conf文件
搜索DocumentRoot 找到下面的位置 自定義的時候可以把這個關閉 ,不關閉好像也沒影響
2、找到<IfModule>這塊,加入下面的代碼
- # 虛擬目錄,訪問D盤下面的web目錄
- <IfModule dir_module>
- # 設置缺省載入頁面
- DirectoryIndex index.html index.htm index.php
- # 設置站點別名,別名與訪問路徑是相關的,取任何名稱都可以(除特殊)
- Alias /myweb "D:/web"
- <Directory D:/web>
- # 設置訪問權限
- Order allow,deny
- Allow from all
- </Directory>
- </IfModule>
修改完成後重啟Apache服務器 在瀏覽器中輸入:http://localhost/myweb/xx.php 來訪問 D:/web 下的文件
安裝Apache配置虛擬目錄