nginx介绍及安装部署

一、nginx介绍

1、作用

nginx news

  • 配置web服务
  • 反向代理、负载均衡

3、nginx高效的原因

  • 基于异步非阻塞/异步IO模型
    • 异步、同步
      • 异步速度快
    • 非阻塞、阻塞
      • 阻塞
        • 进程必须等待磁盘IO完成
      • 非阻塞
        • 进程在等待磁盘IO的同时,可以处理其他事务
  • 基于epoll模型设计的
    • select
      • 周期性询问, 限制最大文件数1024
    • poll
      • 周期性询问,取消最大文件数的限制
    • epoll
      • 通知机制

二、nginx安装部署

1、下载nginx安装包

[root@localhost ~]# wget http://nginx.org/download/nginx-1.18.0.tar.gz

2、安装依赖

[root@localhost ~]# yum install -y gcc openssl-devel pcre-devel zlib-devel

3、编译安装nginx

[root@localhost ~]# tar xf nginx-1.18.0.tar.gz

[root@localhost ~]# cd nginx-1.18.0/

[root@localhost nginx-1.22.1]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 

[root@localhost nginx-1.18.0]# make && make install

三、 nginx相关文件目录

  • nginx安装目录/conf
    • 配置文件 nginx.conf主配置文件
  • nginx安装目录/logs
    • 存放日志
  • nginx安装目录/html
    • 默认网页目录
  • nginx安装目录/sbin
    • 二进制文件

 四、nginx启动管理

1、启动nginx

[root@localhost ~]# /usr/local/nginx/sbin/nginx

[root@localhost ~]# netstat -antp | grep nginx

tcp     0       0 0.0.0.0:80         0.0.0.0:*          LISTEN           9726/nginx: master

[root@localhost ~]# ps -elf | grep nginx

1 S root 9726         1 0 80 0 - 11499 sigsus 15:56 ? 00:00:00 nginx: master process   /usr/local/nginx/sbin/nginx

5 S nginx 9727 9726 0 80 0 - 11612 ep_pol 15:56 ? 00:00:00 nginx: worker process

  • master process 主进程
    • 派生子进程、记录日志、重新加载配置文件
  • worker process 工作进程
    • 接收、处理客户端访问请求

2、设置nginx开机自启动

[root@localhost ~]# sed -ri '$a \/usr/local/nginx/sbin/nginx' /etc/rc.d/rc.local

[root@localhost ~]# chmod a+x /etc/rc.d/rc.local 

 3、停止nginx

[root@localhost ~]# /usr/local/nginx/sbin/nginx -s stop

4、nginx重新加载配置文件

[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload

5、检测配置文件语法

[root@localhost ~]# /usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

6、查看nginx版本

[root@localhost ~]# /usr/local/nginx/sbin/nginx -v

nginx version: nginx/1.18.0

7、查看nginx的配置参数

[root@localhost ~]# /usr/local/nginx/sbin/nginx -V

nginx version: nginx/1.18.0

built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

built with OpenSSL 1.0.2k-fips 26 Jan 2017

TLS SNI support enabled

configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module

  • 21
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值