windows 安装 apache
windows 安装 apache
1. 下载apache
- 访问官网 https://httpd.apache.org/
- 左侧
Essentials
菜单下,找到Download!
- 点击
Files for Microsoft Windows
- 点击
ApacheHaus
- 找到对应的下载版本,如:
Apache 2.4.48 x64
右侧Download Location
下的图标,点击后跳转下载页面,等待下载结束。
2. 安装apache
-
将下载好的压缩包解压到指定的文件夹,如:
D:/soft/
下, 并将文件夹改名为apache
, 此时,apache 实际路径为:D:/soft/apache
. (解压缩可能会多一层,将多余的一层去掉即可) -
打开
D:/soft/apache/conf/httpd.conf
编辑:[第38行左右]- 修改
SRVROOT
为当前apache 路径:
Define SRVROOT "D:/soft/apache"
-
修改端口:【可以不修改,默认为80端口】 [第60行左右]
// 根据需要修改的端口,防止与 nginx 或者其他服务的80端口冲突 Listen 900
-
修改网站根目录。【默认网站根目录是apache 目录下的
htdocs
, 代码中默认显示为:${SRVROOT}/htdocs
】,修改网站根目录需要进行两步操作:[第248行左右]// 第一步: DocumentRoot "H:/apache_webapps" // 第二步: <Directory "H:/apache_webapps"> // 以上两行一般都是紧挨着的~
请确保该修改后的文件夹实际存在,否则启动时会报错:The requested operation has failed!
- 修改
-
配置安装 Apache 主服务
-
打开命令行,进入apache 的 bin 目录
cd /d D:/soft/apache/bin
-
安装主服务:
httpd.exe -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. AH00558: httpd.exe: Could not reliably determine the server's fully qualified domain name, using fe80::39be:4060:3ab2:43d9. Set the 'ServerName' directive globally to suppress this message (OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 : AH00072: make_sock: could not bind to addre ss [::]:443 (OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 : AH00072: make_sock: could not bind to addre ss 0.0.0.0:443 AH00451: no listening sockets available, shutting down AH00015: Unable to open logs
以上报错可知,是因为443端口被其他应用程序占用了,因此需要修改apache 的相关文件,将443端口改成其他端口,如444 等.
解决方法: 主要修改:
D:/soft/apache/conf/extra
目录下的两个文件:httpd-ahssl.conf
和httpd-ssl.conf
,分别修改这两个文件中所有443端口为其他端口【如444】即可。
-
3. 启动apache 服务
- 打开安装目录的bin目录
- 双击运行
ApacheMonitor.exe
, 电脑屏幕右下角即会出现apache图标- 双击点开该图标,点击打开窗口中的 start 即可启动。
A little hug, little gift.
All of little something.
these are our meories.