关闭 Windows IIS 服务 80 端口的2种方法

Windows 2021-09-20 阅读 484 评论 0

问题描述

在 Windows Server 2012 R2 的服务器管理中启用了 IIS 角色后,发现80端口就被占用了,即使把 IIS 停止了,也不能关闭。运行 curl 命令如下:

$ curl -I http://127.0.0.1/
HTTP/1.1 404 Not Found
Content-Length: 315
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Sat, 18 Sep 2021 07:24:04 GMT
Connection: close

发现是 Microsoft-HTTPAPI/2.0 服务器。由于需要在 apache 或者 nginx 使用 80 端口,导致端口冲突错误:nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)

运行 netstat 后,占用 80 端口是 PID 为 4 的进程。

C:\Users\Administrator>netstat -ano | findstr 0.0:80
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4

但是在任务管理器中无法终止该进程。

使用 taskkill /PID 4 同样失败。

C:\Users\Administrator>taskkill /PID 4
错误: 无法终止 PID 为 4 的进程。
原因: 拒绝访问。

解决方法

尝试以下2种方法。

1. 禁用 Web Deployment Service Agent

  1. 打开控制面板(开始 > 控制面板)
  2. 将视图设置从类别更改为小图标或大图标
  3. 打开管理工具
  4. 打开服务
  5. 在列表中找到 “Web Deployment Service Agent”
  6. 右键单击并选择属性
  7. 单击停止
  8. 将其启动值更改为“手动”
  9. 点击应用/确定以保存更改

2. 禁用 BranchCache 服务

跟上一步一样,打开服务界面。

  1. 在列表中找到 “BranchCache”
  2. 右键单击并选择属性
  3. 单击停止
  4. 将其启动值更改为“手动”
  5. 点击应用/确定以保存更改

3. 禁用 W3SVC 服务

跟上一步一样,打开服务界面。

  1. 在列表中找到 “World Wide Web Publishing Service”
  2. 右键单击并选择属性
  3. 单击停止
  4. 将其启动值更改为“手动”
  5. 点击应用/确定以保存更改
最后更新 2022-01-28
MIP.watch('startSearch', function (newVal, oldVal) { if(newVal) { var keyword = MIP.getData('keyword'); console.log(keyword); // 替换当前历史记录,新增 MIP.viewer.open('/s/' + keyword, {replace: true}); setTimeout(function () { MIP.setData({startSearch: false}) }, 1000); } }); MIP.watch('goHome', function (newVal, oldVal) { MIP.viewer.open('/', {replace: false}); });