1、下載的安裝包
http://httpd.apache.org/download.cgi
httpd-2.4.12-win64-VC11.zip將其放到自己的安裝目錄(我的目錄D:/Programs/Apache24)
2、(安裝庫)Required Redistributable
Binaries built on Visual C++ 2012 x64 do not run on Windows XP or Windows Server 2003
These binaries were built with Visual Studio� 2012 x64, be sure to install the required Visual C++ 2012 x64 Redistributable Package, download from;
http://www.microsoft.com/en-us/download/details.aspx?id=30679
3、配置http.conf文件
(Apache24\conf\http.conf)配置文件進行修改-使用記事本打開就行
(1)修改ServerRoot Apache的根路徑:
(38行)ServerRoot"/Apache24"改成=>ServerRoot "D:/Programs/Apache24"
(2)修改ServerName你的主機名稱:
(220行)ServerName localhost:80將前面的#去掉,該屬性在從命令行啟動Apache時需要用到。
(3)修改端口Listen(我這邊80端口唄占用了,所以修改成了7070端口)
(60行)Listen 80→Listen7070
4、安裝啟動Apache
win+x,選擇“命令提示符(管理員)”。接着進入D:\Programs\Apache24\bin目錄下
To Install Apache as a service:
In most cases you will want to run Apache as a Windows Service.
To do so you install Apache as a service by typing at the command prompt [1];
httpd -k install
You can then start Apache by typing
httpd -k start
Apache will then start and eventually release the command prompt window.
[1] You have to run the command prompt as Administrator in Windows Vista/7/2008/8/8.1/10/2012/
Other Command line options:
Stop Apache
httpd -k stop
Restart Apache
httpd -k restart
Uninstall Apache Service
httpd -k uninstall
Test Config Syntax
httpd -t
Version Details
httpd -V
Command Line Options List
httpd -h
5、驗證服務是否啟動
打開IE,然后在地址欄輸入:"http://localhost:7070" 或者 "http://127.0.0.1:7070" 可以看到Apache安裝完成的成功頁面;以后網頁的存在位置就在 "D:/Programs/Apache24/htdocs" 目錄。進入下面的界面:
6、卸載服務
打開電腦 “開始”->“運行”-> cmd,進入DOS命令行窗口,進入Apache安裝目錄,如 D:\Programs\Apache24\bin目錄。(使用管理員權限)
輸入命令:httpd.exe -k uninstall 卸載Apache服務。(注:httpd.exe -k install 命令是安裝Apache 服務)。
7、常見錯誤:
(1)
AH00369: Failed to open the Windows service manager, perhaps you forgot to log in as Adminstrator?
原因及解決:沒有管理員權限,用管理員權限打開命令行就可以。
(2)
httpd: Syntax error on line 39 of D:/Programs/Apache24/conf/httpd.conf: ServerRoot must be a valid directory
原因及解決:Apache服務地址錯誤,修改httpd.conf的 (38行)行ServerRoot "/Apache24"中的目錄為實際Apache目錄,注意"/"
(3)
Errors reported here must be corrected before the service can be started.
很多人看到Errors都會想怎么啟動就遇到錯誤啊,首先需要強調的是這句話並不是說Apache啟動錯誤。 這句話是Apache內置的啟動提示語句,暫時沒有找到取消和更改的方法。
這句話英文翻譯后可以理解為:
Apache每次啟動都會檢測配置文件httpd.conf有沒有錯誤,如果在Errors reported here must be corrected before the service can be started.這句話下邊出現提示或錯誤時必須先把這些問題解決了才能成功啟動Apache服務。
所以大家看到Errors reported here這句下邊沒有任何提示則說明Apache啟動很成功!可以放心進行其他相關操作。