温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

nginx服务器的下载安装与使用方法

发布时间:2021-07-29 13:43:06 来源:亿速云 阅读:146 作者:chen 栏目:开发技术

本篇内容介绍了“nginx服务器的下载安装与使用方法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

下载

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

解压

将下载后的 nginx-1.19.8.zip 压缩包解压缩到 D:/applications 目录下。

解压后的目录结构如下:

<img src="images\nginx-directory.png"  />

配置

conf 目录中找到 nginx.conf 文件,先备份后再修改该文件。

修改之后的内容如下:

worker_processes  1;
 
events {
    worker_connections  1024;
}
 
 
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    sendfile        on;
 
    keepalive_timeout  65;
 
 
    server {
        listen       80;
        server_name  localhost;
 
        location / {
            root D:/mycodes/movable-termination;
            index  index.html index.htm;
        }
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root  D:/mycodes/movable-termination ;
        }
 
    }
 
}

注意

1.listen 之后的 80 表示 监听端口 ( 80 是 WWW 服务的默认端口 )

2.server_name 之后的 localhost 表示本地主机 ,将来在浏览器地址栏中可以通过 http://localhosthttp://localhost:80 来访问

3 localtion / 选项下的 root 选项用于确定 WWW服务的 根目录 ,即当访问 http://localhost:80/index.html 时会在 root 对应的目录下寻找 index.html ,也就是 http://localhost:80/index.html:80 之后的 / 所对应的目录 ,location = /50x.html 选项中的 root 表示服务端发生错误后的跳转页面所在的目录

启动

首先进入到 nginx 目录下:

cd nginx-1.19.8

在命令提示符中启动 nginx :

start nginx

启动之后可以在 任务管理器 中查看到两个 nginx 进程

修改配置后重新加载生效:

nginx -s reload

有序退出

nginx -s quit

快速关闭

nginx -s stop

可能会因为多次启动 nginx 导致启动了多个 nginx 进程,此时需要列出这些进程相关的信息:

tasklist /fi "imagename eq nginx.exe"

如果需要将这些进程全部杀死,可以使用以下命令:

taskkill /f /t /im nginx.exe

注意: tasklist 、taskkill 、start 都是 Windows 自带的命令,不是 nginx 提供的。

“nginx服务器的下载安装与使用方法”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI