• windows下nginx的安装使用及解决80端口被占用nginx不能启动的问题


    目前nginx已被广泛使用,今天我们首先来讲讲nginx在Windows下的搭建。

    1、安装

    nginx官网下载一个Windows下使用的最新版本,目前是1.11.10,如图:

    下载下来解压缩就可以。

    2、运行

    运行nginx,报错:

    1
    [emerg] 10348#10940: 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)

    如图:

    在log日志中也能看到,打开:

    1
    nginx-1.11.10logserror.log

    如图:

    nginx默认要使用80端口,但Windows下80端口是被占用的,查一下:

    被一个pid为4的进程占用,查一下:

    是个系统进程,任务管理器里看一下:

    果然。

    3、问题解决

    解决的办法就是让系统进程不再占用80端口,需要修改注册表。

    3.1 打开注册表

    启动栏输入regedit

    3.2 找到注册项并修改

    找到

    1
    HKEY_LOCAL_MACHINESYSTEMCurrentControlSetservicesHTTP

    里面有一个REG_DWORD类型的项Start注册项:

    原值为3:

    改为0:

    3.3 重启操作系统

    重启Windows系统,原来的系统进程就不会占用80端口了。

    4、重新运行nginx

    在nginx的安装目录下运行:

    1
    start nginx.exe

     

    或者:

    1
    nginx.exe

    如图:

    在任务管理器中能够看出后台会有两个进程被启动起来:

    5、关闭nginx

    1
    nginx.exe -s stop

     

    或者:

    1
    nginx.exe -s quit

    如果没有成功可以再查看logs下的error.log原因,以下为其它操作命令

    nginx -s stop quick exit
    nginx -s quit graceful quit
    nginx -s reload changing configuration, starting a new worker, quitting an old worker gracefully
    nginx -s reopen reopening log files

    6、配置测试

    我们在cmd下运行nginx

    启动成功,出错的话,可以查询日志(日志路径是配置文件指定的,你可以修改存到其它位置)

    关闭所有Nginx所有进程: taskkill /im /f Nginx.exe。 这个命令很好用,下面两个命令有时候无法关闭nginx。
    关闭Nginx进程: nginx -s stop / nginx -s quit

    stop可以快速停止nginx,但是可能不会保存相关信息;而quit是完整有序的停止nginx,这个过程会保存相关信息。

    载入指定配置文件

    C:server ginx-1.7.2>start nginx.exe -c conf/default.conf

    如果80端口被vs占用

    打开命令行cmd 
    sc config http start= disabled 
    重启电脑,netstat查看,80端口没被占用,搞定。(禁用后vs不可使用) 
    恢复http开机启动命令:(开启后vs恢复使用) 
    sc config http start= demand

  • 相关阅读:
    在Eclipse里连接Tomcat部署到项目(maven项目和web项目都适用)
    Eclipse里Tomcat报错:Document base ……does not exist or is not a readable directory(图文详解)
    Automatic logon configuration on Linux OS
    uva 10655
    CentOS6.5与window远程桌面配置
    operator= 复制操作符的意外
    Window平台搭建Redis分布式缓存集群 (一)server搭建及性能測试
    安卓自己定义日历控件
    详解2进制,10进制,16进制,8进制,36进制
    HDU 1394 Minimum Inversion Number (线段树 单点更新 求逆序数)
  • 原文地址:https://www.cnblogs.com/kevin860/p/8914835.html
Copyright © 2020-2023  润新知