windows下搭建nginx

下载nginx。

官网地址:

http://nginx.org/

下载地址:

http://ngxinx.org/en/download.html

解压nginx到C盘根目录,重命名为nginx。

执行nginx.exe -t检查配置是否正确。

执行nginx.exe启动nginx。

注:

若想将nginx配置为一个服务,开机自启动需要有一下操作。

1、下载Windows Service Wrapper。

扫描二维码关注公众号,回复: 942457 查看本文章

官网地址:

https://github.com/kohsuke/winsw/

下载地址:

http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/

2、下载后将文件"winsw-1.19-bin.exe"重命名为"nginx-service.exe",并复制到nginx根目录。

3、在nginx根目录编写nginx-service.xml文件

<?xml version="1.0" encoding="UTF-8" ?>

<service>

    <id>Nginx</id>

    <name>Nginx</name>

    <description>本服务用于加载Nginx服务,请确保开机启动</description>

    <logpath>C:\nginx\logs</logpath>

    <executable>nginx.exe</executable>

    <stopexecutable>nginx.exe</stopexecutable>

    <stopargument>-s</stopargument>

    <stopargument>stop</stopargument>

    <logmode>rotate</logmode>

</service>

4、安装Nginx服务系统

以管理员的身份运行命令nginx-service.exe install

卸载Nginx服务系统

以管理员的身份运行命令nginx-service.exe uninstall

5、在服务管理里将Nginx服务启动。

猜你喜欢

转载自blog.csdn.net/qq_36369292/article/details/80090419
今日推荐