点击Apache httpd 2.4.46 Released 2020-08-07栏下的Download
点击Apache HTTP Server 2.4.46 (httpd): 2.4.46 is the latest available version 2020-08-07栏下的Files for Microsoft Windows
点击Downloading Apache for Windows栏下的ApacheHaus
我因为之前就装了VC15(好像是装mysql8.0时要装的),所以点击中间的Apache 2.4 VC15
自动跳转到下面Apache 2.4.46 x64栏,可以看到右边12.2MB,点击Download Location下边的下载按钮,我选左边的下载按钮,下载源不同而已,文件是一样的
解压到D盘下并把Apache24重命名为Apache,用管理员身份打开命令行并进入D:\Apache\bin,若加了D:\Apache\bin\httpd.exe这个环境变量,可在任意路径下调用下面的httpd指令
D:\Apache\bin>httpd -t,没有报错,如果报错httpd: Syntax error on line 40 of D:/Apache/conf/httpd.conf: ServerRoot must be a valid directory,把那个路径改成D:\Apache
D:\Apache\bin>httpd -k install -n Apache,最后返回
Testing httpd.conf ....
Errors reported here must be corrected before the service can be started,表示没有问题
D:\Apache\bin>httpd -k start -n apache 启动apache服务
修改了D:\Apache\conf\httpd.conf中的端口为8044
D:\Apache\bin>httpd -k restart -n apache 重启apache服务,在修改了D:\Apache\conf\httpd.conf后需要执行这个指令1
浏览器访问127.0.0.1:8044,成功
D:\Apache\bin>httpd -k stop -n apache 停止apache服务
The 'Apache' service is stopping.
The 'Apache' service has stopped.
浏览器访问127.0.0.1:8044,失败
至此,apache安装完成,以后使用时可以有三个办法:
法一:以管理员身份打开命令行
C:\Windows\system32>net start apache
Apache 服务正在启动 .
Apache 服务已经启动成功。
C:\Windows\system32>net stop apache
Apache 服务正在停止.
Apache 服务已成功停止。
法二:运行D:\Apache\bin\ApacheMonitor.exe
点击右边的start与stop按钮进行开关
法三:以管理员身份打开命令行并进入到D:\Apache\bin
操作方法同上面的测试方法,注意更改httpd.conf后reload只可以法三
记住路径不要变