解压 从官网下载的 httpd-2.4.35-win64-VC15.zip文件 到 E:\Apache\后 以管理员权限打开cmd窗口 ,执行如下
E:\Apache\Apache24\bin>httpd -k install -n "Apache"
Installing the 'Apache' service
The 'Apache' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
httpd: Syntax error on line 39 of E:/Apache/Apache24/conf/httpd.conf: ServerRoot must be a valid directory
E:\Apache\Apache24\bin>httpd -t
AH00526: Syntax error on line 250 of E:/Apache/Apache24/conf/httpd.conf:
DocumentRoot 'C:/Apache24/htdocs' is not a directory, or is not readable
E:\Apache\Apache24\bin>httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::a80a:615:8694:e19b. Set the 'ServerName' directive globally to suppress this message
Syntax OK
E:\Apache\Apache24\bin>httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::a80a:615:8694:e19b. Set the 'ServerName' directive globally to suppress this message
Syntax OK
E:\Apache\Apache24\bin>httpd -t
Syntax OK
E:\Apache\Apache24\bin>httpd -k start -n "Apache"
E:\Apache\Apache24\bin> //至此 表示 名字为Apache 的服务 在windows中成功启动
其中E:/Apache/Apache24/conf/httpd.conf 配置文件中 修改了两处地方:分别是:
Define SRVROOT "E:/Apache/Apache24"
ServerRoot "${SRVROOT}"
#ServerName www.example.com:80
ServerName localhost
在Apache服务启动成功后,在浏览器页面输入地址:localhost 。页面显示 It works! 表示服务器启动成功