0
点赞
收藏
分享

微信扫一扫

C# WPF如何自定义控件ComboBox

夕颜合欢落 03-02 06:30 阅读 5
nginx运维

文章目录


简介

  • Web服务器,高性能,Http与反向代理的服务器。
  • 启动后浏览器输入 http://localhost/ 显示欢迎页面就是启动成功了。
  • 在nginx安装目录下cmd就可以进入命令行了

在这里插入图片描述

  • conf:存在Nginx配置文件的目录
    • Nginx的配置文件是在conf目录下的nginx.conf文件
  • docs:存放Nginx文档的目录
  • html:存放静态html文件的目录
  • logs:存放Nginx日志的目录
  • temp:存放临时文件的目录

安装

Ubuntu安装

# 1. 更新仓库信息
sudo apt-get update
# 2. 安装nginx
sudo apt-get install nginx
# 3. 验证安装
sudo nginx -V

CentOS安装

CentOSLinux发⾏版可以使⽤yum来安装。
# 1. 安装EPEL仓库
sudo yum install epel-release
# 2. 更新repo
sudo yum update
# 3. 安装nginx
sudo yum install nginx
# 4. 验证安装
sudo nginx -V

windows

https://nginx.org/en/download.html
下载解压,

常用命令

  • windows:如果你没有把该目录加入到系统的path中,请在nginx当前目录下,打开cmd命令行,然后输入命令。
  • linux直接打开终端即可。
查看nginx的版本号
nginx -v
    

查看nginx详细信息
nginx -V(大写)


    
启动服务
nginx
没有提示信息就表明已经启动了。
打开浏览器输入localhost显示nginx欢迎页面表示成功启动。


查看进程
ps -ef | grep nginx
root        3572       1  0 10:59 ?        00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data    3574    3572  0 10:59 ?        00:00:00 nginx: worker process
www-data    3575    3572  0 10:59 ?        00:00:00 nginx: worker process
www-data    3576    3572  0 10:59 ?        00:00:00 nginx: worker process
www-data    3577    3572  0 10:59 ?        00:00:00 nginx: worker process
www-data    3578    3572  0 10:59 ?        00:00:00 nginx: worker process
www-data    3579    3572  0 10:59 ?        00:00:00 nginx: worker process
root        7787    4311  0 11:29 pts/1    00:00:00 grep --color=auto nginx
master 只有一个。表示主进程,负责读取与验证配置文件,管理worker进程
worker 可以多个。是实际工作进程,


查看端口占用情况
lsof -i:80


重载配置,每次修改后都要重新加载配置
nginx -s reload


快速停止或关闭
nginx -s stop


正常停止或关闭
nginx -s quit


重新打开日志文件
nginx -s reopen


检查配置文件nginx.conf是否报错
nginx -t

配置文件 nginx.conf

核心一共三部分
1. 最外层的全局块:	里面是全局的核心配置
2. events块:		里面是服务器客户端之间的网络连接配置
3. http块:			反向代理,负载均衡,虚拟主机
	- http块里面的每一个server块都代表一个虚拟主机

nginx -V

输入nginx -V查看详细信息
----------------------------------------------------
----------------------------------------------------
这是展示样例,里面都是nginx的信息

[root@yx-virtual-machine /] # nginx -V
nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 3.0.2 15 Mar 2022
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -ffile-prefix-map=/build/nginx-zctdR4/nginx-1.18.0=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-compat --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --add-dynamic-module=/build/nginx-zctdR4/nginx-1.18.0/debian/modules/http-geoip2 --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_sub_module
----------------------------------------------------
----------------------------------------------------

寻找里面的--conf-path=/etc/nginx/nginx.conf 即是配置文件的位置
通过cat命令打开文件  
cat /etc/nginx/nginx.conf

----------------------------------------------------
-----------------------------------------------------
# 全局配置

# work进程的数量
worker_processes  4;


# events事件配置
events {
    worker_connections  1024;
}


# htt配置
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;


    # 负载均衡
    upstream fzjh001{
        # 127.0.0.1是我本机地址,8081,8082是我服务器程序运行的端口
        # weight表示权重
        server 127.0.0.1:8081 weight=1;
        server 127.0.0.1:8082 weight=2;
    }

    server {
        listen       80;
        server_name  localhost;

        # 匹配输入的URL
        location / {
                # root是关键字,html指的是nginx安装目录下的html文件夹,里面放项目。
                # 你也可以指定其他文件夹放项目,只要在nginx文件夹以内就好
            root   html;
                # index是关键字,表示默认打开的网址
                # 后面两个是打开的网页文件的名字,第一个能用就不打开第二个了。
            index  index.html index.htm;
                # 反向代理
                # 参数是上面负载均衡自定义的名字。
            proxy_pass http://fzjh001;
        }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
}


----------------------------------------------------
----------------------------------------------------
# 匹配输入的URL
location / {
    # root是关键字,html指的是nginx安装目录下的html文件夹,里面放项目。
    # 你也可以指定其他文件夹放项目,只要在nginx文件夹以内就好
    root   html;
    # index是关键字,表示默认打开的网址
    # 后面两个是打开的网页文件的名字,第一个能用就不打开第二个了。
    index  index.html index.htm;
}

work数量
# work进程的数量
worker_processes  1;

反向代理 & 负载均衡

正向代理:代理客户端,假装是客户端访问服务器
反向代理:代理服务端,假装服务器服务客户端

举报

相关推荐

0 条评论