1、官網下載Apache
官網地址:https://httpd.apache.org/css
點擊Download--->點擊Files for Microsoft Windows--->點擊ApacheHaus--->選擇版本(點擊Apache 2.4 VC11)----->解壓下載好的壓縮包文件,移動文件夾Apache24到你想要的位置。html
2、安裝Apache
1.移動文件Apache到E:\WAMP\Apache2.4。【解壓路徑最好不要用中文。】apache
2.命令行到Apache下面的bin目錄,錄入命令[ httpd -k install ]安裝。瀏覽器
注:若是提示錯誤計算機中丟失 msvcr110.dll文件,請到http://www.microsoft.com/zh-CN/download/details.aspx?id=30679 這個網址來進行相關程序的下載服務器
![](http://static.javashuo.com/static/loading.gif)
報錯的大概意思:在啓動Apache服務以前必須修正一個錯誤,在E:\WAMP\Apache2.4\conf 的httpd.conf文件的第39行,ServerRoot必須是有效的。app
報錯緣由:httpd.conf裏面配置的ServerRoot路徑跟實際路徑不一致,致使路徑無效。編輯器
3.修改httpd.conf文件ide
![](http://static.javashuo.com/static/loading.gif)
4.啓動Apache服務命令啓動Apache服務:【 httpd -k start 】post
![](http://static.javashuo.com/static/loading.gif)
五、安裝成功驗證測試
開始-->運行-->services.msc-->肯定(或回車鍵Enter)--->服務列表中查看Apache服務,存在說明安裝成功。
![](http://static.javashuo.com/static/loading.gif)
補充:瞭解Apache文件夾裏的相關目錄和文件
![](http://static.javashuo.com/static/loading.gif)
- bin目錄(主程序文件)/httpd.exe 圖標(羽毛)
- conf目錄(配置文件目錄)/httpd.conf(主配置文件)和extra文件夾(擴展配置目錄)/httpd-vhosts.conf(虛擬主機配置文件)
- htdocs目錄(站點根目錄)-----域名對應的目錄
6.參考文章:
Apache服務器的下載與安裝
Apache 下載+安裝
3、Apache相關配置------主機配置
1.httpd.conf------conf目錄下
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
2.hosts文件----位置通常在C:\WINDOWS\system32\drivers\etc
![](http://static.javashuo.com/static/loading.gif)
注:127.0.0.1永遠表明本地ip
3.httpd.exe-----bin目錄下
- cmd裏dir能夠查看當前目錄的內容,cd能夠更改目錄的位置
- httpd.exe文件能夠進行Apache服務的啓動(httpd.exe - k start),中止(httpd.exe - k stop)和從新啓動(httpd.exe - k restart)
- httpd.exe文件能夠對配置文件進行語法檢查(httpd -t)
![](http://static.javashuo.com/static/loading.gif)
注:在win10系統中,須要用管理員的身份運行
4.window環境變量:window的環境變量記錄了不少的路徑,當在cmd窗口執行一個命令時,若是當前的目錄找不到咱們要執行的文件時,window會找到環境變量中所記錄的位置,依次進行查找,找到了就運行,找不到則報錯
- .「計算機」右鍵 → 「高級系統設置」 → 「高級」 → 「環境變量」
![](http://static.javashuo.com/static/loading.gif)
- .點擊系統變量的「新建」→ 變量名"HTTPD_HOME" → 變量值「E:\WAMP\Apache2.4」(Apache安裝路徑)→ 「肯定」
注意:變量值後面不能添加分號「;」,不然配置不成功。
- .點擊系統變量的「編輯」(沒有時新建)→ 變量名"Path" → 變量值「%HTTPD_HOME%\bin;」(Apache的bin目錄的路徑)→ 「肯定」
注意:變量值後面的分號「;」必須是英文分號。path:操做系統提供的環境變量。classpath:程序中引用的類所在的路徑。
![](http://static.javashuo.com/static/loading.gif)
- .設置成功後,手動重啓cmd,錄入命令[ httpd -k restart ]重啓Apache服務。如果啓動,說明系統環境變量配置成功。
![](http://static.javashuo.com/static/loading.gif)
- 以上所在window7系統裏的安裝,window10裏面安裝更加便捷,能夠自行百度
4、Apache相關配置------虛擬主機配置:使用一個Apache軟件配置多個主機(域名)
1.開啓擴展配置文件(默認是關閉的)----httpd.conf
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
2.配置虛擬主機-----httpd-vhosts.conf
![](http://static.javashuo.com/static/loading.gif)
3.注意的問題:
![](http://static.javashuo.com/static/loading.gif)
- 若是使用了虛擬主機,則默認必須所有使用虛擬主機,即以前的默認網站也必須經過虛擬主機方式配置,不然訪問不到,參考文章:Apache HTTP Server 虛擬主機配置
-
Chrome 瀏覽器 63版本之後,全部的 .dev 和 .app 後綴的網址都將會自動將 HTTP 轉到 HTTPS 上,因此若是使用上面的.dev後綴的網址,會出如今Chrome沒法訪問的狀況,可是在其餘瀏覽器能夠正常訪問,緣由就出在這(確實被坑了一道!!!)
5、Apache相關配置------外部配置文件
1.開啓外部配置文件httpd.conf中開啓AllowOverride All
![](http://static.javashuo.com/static/loading.gif)
2..hatacss文件建立(只能經過編輯器另存的方式來建立)---此文件中的配置不須要從新啓動Apache
3.補充:自定義錯誤提示頁面(ErrorDocument)
![](http://static.javashuo.com/static/loading.gif)