win10安装nginx的配置和使用方法(图文)

window10系统安装nginx服务,提供网页方面的服务。下面为详细图文安装配置教程。

1)下载nginx软件

官方下载地址:http://nginx.org/en/download.html
在这里插入图片描述

2)解压缩软件

unzip nginx-1.20.1.zip 或者 使用解压缩软件,下面是解压缩后的内容
在这里插入图片描述

3)CMD命令行启动nginx

cd nginx-1.20.1
start nginx
nginx -t
tasklist /fi “imagename eq nginx.exe”
nginx -s reload //重新加载
nginx -s stop //此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程
nginx -s quit //此方式停止步骤是待nginx进程处理任务完毕进行停止

在这里插入图片描述

说明:

  1. 解压的Nginx路径不能有中文,否则启动不起来
  2. 在命令窗口启动后会有各弹窗一闪而逝,不用管他
  3. start nginx:为启动命令
  4. nginx -t 为启动状态检查命令

4)测试、访问

正常80端口不被占用的情况下,url输入: localhost,页面显示:
在这里插入图片描述

5)配置两个服务的代码:

    server {
    
     
        listen       80; 
        server_name  localhost; 
        location / {
    
     
            root   html/default; 
            index  index.html index.htm; 
        } 
 
    } 
#set port 
    server {
    
     
            listen       8001;          
            server_name  localhost; 
            location /{
    
     
                root   html/demo; 
                index  index.html index.htm; 
            } 
        } 

6)linux版nginx常用命令

帮助命令:nginx -h
启动Nginx服务器 :sudo nginx
查看进程: ps aux | grep nginx
配置文件路径:/usr/local/nginx/conf/nginx.conf
检查配置文件:sudo nginx -t
指定启动配置文件:sudo nginx -c /usr/local/nginx/conf/nginx.conf
暴力停止服务:sudo nginx -s stop
优雅停止服务:sudo nginx -s quit
重新加载配置文件:sudo nginx -s reload

猜你喜欢

转载自blog.csdn.net/cuclife/article/details/131323883
今日推荐