一、下载

目录文件:

二、运行方式

(1)直接双击nginx.exe,双击后一个黑色的弹窗一闪而过

(2)打开cmd命令窗口,切换到nginx解压目录下,输入命令 nginx.exe 或者 start nginx ,回车即可

三、查看任务进程是否存在,dos或打开任务管理器都行

1、dos方式:

tasklist /fi "imagename eq nginx.exe"

如图:

2、任务管理器方式

打开任务管理器在进程中,打开详细信息里面能看到隐藏的nginx.exe进程

四、目录结构

如图所示:

1、日志

在nginx目录中的logs文件夹下error.log是日志文件,access.log是请求日志文件

error.log常见的错误:

(1)端口号被占用

(2)nginx文件夹路径含中文

其他错误就详细看log中的描述

2、站点配置

3、nginx服务的配置文件

代码如下:

#user  nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; server {
listen 80;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }

简化如下:

worker_processes  1;

events {
worker_connections 1024; #1、worker进程连接数量
} http {
include mime.types; #2、include表示纳入mime.types文件的配置
default_type application/octet-stream;
#3、default_type如果Web程序没设置,Nginx也没找到对应文件的扩展名的话,就使用默认的Type,这个在Nginx 里用 default_type定义: default_type application/octet-stream,这是应用程序文件类型的默认值。 sendfile on;
#4、sendfile: 设置为on表示启动高效传输文件的模式。sendfile可以让Nginx在传输文件时直接在磁盘和tcp socket之间传输数据。如果这个参数不开启,会先在用户空间(Nginx进程空间)申请一个buffer,用read函数把数据从磁盘读到cache,再从cache读取到用户空间的buffer,再用write函数把数据从用户空间的buffer写入到内核的buffer,最后到tcp socket。开启这个参数后可以让数据不用经过用户buffer。 keepalive_timeout 65; #5、链接超时Nginx 返回 HTTP 408(Request Timed Out)。 #6、服务配置
server {
listen 80;
server_name localhost; location / {
root html;
index index.html index.htm;
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} } }

mime.types文件

包含文件类型如下:

4、多站点配置(基于域名的配置,使用不同的域名来访问)

1、分别创建vhosts、和htmls文件夹

如图:

2、在创建vhosts文件夹里面创建*.conf文件(域名对应一个.conf文件)

如图:

代码如下:

server
{
listen 80;
server_name www.logr.cn; location / {
root C:\Users\Alix\Desktop\nginx-1.17.6\htmls; #静态文件目录
index index.php index.html index.htm default.php default.htm default.html; //默认访问文件
}
}

3、在创建htmls文件夹里面放入index.html文件

如图:

4、nginx.conf 在配置文件中更改引入(http下引入配置文件*.conf即等同于添加一个server服务)

worker_processes  1;

events {
worker_connections 1024;
} http { include mime.types;
default_type application/octet-stream; sendfile on; keepalive_timeout 65; include ../vhosts/*.conf; #包含vhosts目录的所有站点配置文件 server {
listen 80;
server_name localhost; location / {
root html;
index index.html index.htm;
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} } }

预览效果:

注意:

修改hosts文件

C:\Windows\System32\drivers\etc\hosts

127.0.0.1 www.logr.cn

如图:

4、多站点配置(基于多端口的配置)

1、win下追加域名访问

2、更改配置文件

一、Nginx多站点配置的更多相关文章

  1. nginx高性能WEB服务器系列之五--实战项目线上nginx多站点配置

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

  2. Ubuntu系统下lnmp环境搭建和Nginx多站点配置

    最近需要使用Ubuntu作为服务器搭建Lnmp环境,顺便将操作过程写下来,与大家分享.如有不足之处,欢迎大家提出不同意见.(本文默认读者已经熟悉相关linux命令的使用,比如创建文件和文件夹,编辑文件 ...

  3. nginx 多站点配置方法集合(转)

    关于nginx的多站设置,其实和apache很相似,假设我们已经有两个域名,分别是:www.websuitA.com和www.websuitB.com.并且这两个域名已经映射给了IP为192.168. ...

  4. nginx 多站点配置方法

    关于nginx的多站设置,其实和apache很相似哒. 假设我们已经有两个域名,分别是:www.websuitA.com和www.websuitB.com.并且这两个域名已经映射给了IP为192.16 ...

  5. 二、Nginx多站点配置(参考宝塔的)分析

    一.基于宝塔配置文件分析(站的配置文件) 新增的站点配置即添加server并包含在nginx内 查找文件: 文件内容: 二.伪静态 伪静态是一种可以把文件后缀改成任何可能的一种方法,如果我想把php文 ...

  6. nginx多站点配置

    一.安装nginx https://yq.aliyun.com/articles/101144?spm=5176.10695662.1996646101.searchclickresult.70af9 ...

  7. Nginx 多站点配置

    最近学习和练习的时候,为Laravel应用程序添加了好几个站点,有些程序删除之后站点却还留着,这让强迫症感到非常难受,上次解决了这个问题之后并没有记录一下,于是导致今天又花了很多时间折腾,所以特地来写 ...

  8. 简单的 nginx 多站点配置

    测试环境:基于CentOS6.8 编译安装LNMP(http://www.cnblogs.com/afee666/p/6836161.html) 一 需求 在一个 VPS 主机上配置 web 服务器, ...

  9. nginx高性能WEB服务器系列之六--nginx负载均衡配置+健康检查

    nginx系列友情链接:nginx高性能WEB服务器系列之一简介及安装https://www.cnblogs.com/maxtgood/p/9597596.htmlnginx高性能WEB服务器系列之二 ...

随机推荐

  1. Java-获取当前IP归属地

    知道IP,获取当前IP归属地的Java程序: package Main; import java.io.BufferedReader; import java.io.DataOutputStream; ...

  2. Python Deque 模块使用详解,python中yield的用法详解

    Deque模块是Python标准库collections中的一项. 它提供了两端都可以操作的序列, 这意味着, 你可以在序列前后都执行添加或删除. https://blog.csdn.net/qq_3 ...

  3. 网络实验 02-交换机的Telnet远程登录设置

    交换机的Telnet远程登录设置 一.实验目标 掌握采用telnet方式配置交换机的方法 二.技术原理 1. 配置交换机的管理IP地址(计算机的IP地址与交换机管理IP地址在同一网段) 2. 为tel ...

  4. SQL常见面试题(借书卡表_图书表_借书记录表)

    问题描述: 本题用到下面三个关系表: CARD 借书卡:          CNO 卡号,NAME 姓名,CLASS 班级 BOOKS 图书:           BNO 书号,BNAME 书名,AU ...

  5. Mac OS下使用pyenv管理Python版本

    问题的由来 在开发过程中,可能会遇到多个版本同时部署的情况. Mac OS自带的Python版本是2.x,自己开发需要Python3.x 系统自带的是2.6.x,开发环境是2.7.x 由于Mac机器系 ...

  6. CentOS 7 分区

    必须的分区 boot分区: 作用:引导分区,包含了系统启动的必要内核文件,即使根分区顺坏也能正常引导启动 一般这些文件所占空间在200M以下, 分区建议:分区的时候可选100M-500M之间,如果空间 ...

  7. 【Ansible】记一次技术博客害死人的经历——ansible模板变量注入探究

    风和日丽,夏天的北京湿热并举,睁不开的眼睛里,横竖都看着是“吃人”. 带薪学习的日子不好过,要在几天内迅速掌握导师下发要求学习的技能,看着以前一起蹲IT坑的同事人来人往,用隔壁同性黄同学的话来说,就是 ...

  8. Redis高级主题

    Redis高级主题   持久化 Redis 支持持久化, 其持久化数据有两种方式. 两种可以同时使用. 如果同时使用, Reids 在重启时将使用 AOF 方式来还原数据. RDB 按照一定策略定时同 ...

  9. 树莓派4B 串口通信

    提前下载安装Glade图形编辑器 参考 树莓派4B安装netcore 环境部署.发布.执行操作 准备串口设备本文使用串口控制继电器设备 如图 1.发现串口 void GetSerialPort() { ...

  10. hashmap C++实现

    hashmap.h #ifndef _HASHMAP_H_ #define _HASHMAP_H_ template<class Key, class Value> class HashN ...