广告
返回顶部
首页 > 资讯 > 服务器 >nginx服务器的下载安装与使用详解
  • 505
分享到

nginx服务器的下载安装与使用详解

2024-04-02 19:04:59 505人浏览 薄情痞子
摘要

下载 Http://Nginx.org/en/download.html 解压 将下载后的 nginx-1.19.8.zip 压缩包解压缩到 D:/applications 目录下。

下载

Http://Nginx.org/en/download.html

解压

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

解压后的目录结构如下:

<img src="images\nginx-directory.png" style="zoom:80%;border:1px solid gray;" />

配置

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服务器的下载安装与使用详解的文章就介绍到这了,更多相关nginx服务器下载内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: nginx服务器的下载安装与使用详解

本文链接: https://www.lsjlt.com/news/131398.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作