nginx的基本介绍

什么是nginx

Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,是一个做网站服务器的软件,是静态的网站。

Nginx是一款轻量级Web服务器反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。

[root@GOLANG ~]# curl -O https://nginx.org/download/nginx-1.22.1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1048k  100 1048k    0     0   128k      0  0:00:08  0:00:08 --:--:--  246k

安装相关包
[root@GOLANG nginx-1.22.1]# yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel autoconf automake make psmisc net-tools lsof vim wget -y

编译安装
[root@GOLANG nginx-1.22.1]# ./configure --prefix=/usr/local/wjz99 --user=wjz --group=wjz --with-http_ssl_module --with-threads --with-http_v2_module --with-http_stub_status_module --with-stream --with-http_gunzip_module

Configuration summary
  + using threads
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/local/wjz99"
  nginx binary file: "/usr/local/wjz99/sbin/nginx"
  nginx modules path: "/usr/local/wjz99/modules"
  nginx configuration prefix: "/usr/local/wjz99/conf"
  nginx configuration file: "/usr/local/wjz99/conf/nginx.conf"
  nginx pid file: "/usr/local/wjz99/logs/nginx.pid"
  nginx error log file: "/usr/local/wjz99/logs/error.log"
  nginx http access log file: "/usr/local/wjz99/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
[root@GOLANG src]# cd /usr/local/wjz99
[root@GOLANG wjz99]# ls
conf  html  logs  sbin
[root@GOLANG wjz99]# 
conf	存放nginx的配置文件
html	存放网站的网页的目录
logs	存放日志
sbin	存放nginx的启动程序


几种观察nginx是否开启的方式

[root@GOLANG sbin]# ./nginx
[root@GOLANG sbin]# ps aux | grep nginx   看进程
root       1455  0.0  0.0  46232  1172 ?        Ss   19:00   0:00 nginx: master process ./nginx
wjz        1456  0.0  0.0  46692  1924 ?        S    19:00   0:00 nginx: worker process
root       1584  0.0  0.0 112824   988 pts/0    S+   19:55   0:00 grep --color=auto nginx
[root@GOLANG sbin]# PATH=/usr/local/wjz99/sbin/:$PATH  修改环境变量,可以在任何目录下启动nginx
[root@GOLANG sbin]# which nginx
/usr/local/wjz99/sbin/nginx
[root@GOLANG sbin]# cd ..
[root@GOLANG wjz99]# cd
[root@GOLANG ~]# pwd
/root
[root@GOLANG ~]# nginx
[root@GOLANG ~]# nginx -s stop
[root@GOLANG ~]# ps aux | grep nginx
root       1652  0.0  0.0 112824   988 pts/0    S+   20:07   0:00 grep --color=auto nginx
[root@GOLANG logs]# tail -f access.log     看日志
[root@GOLANG ~]# netstat -anplut   
[root@GOLANG ~]# lsof -i:80    看端口 
[root@GOLANG ~]# ss -anplut

几种关闭方式

在这里插入图片描述

[root@GOLANG conf]# ps aux|grep nginx
root       1897  0.0  0.0  46232  1172 ?        Ss   21:05   0:00 nginx: master process nginx
wjz        1898  0.0  0.0  46692  2156 ?        S    21:05   0:00 nginx: worker process
root       2026  0.0  0.0 112824   988 pts/0    S+   21:32   0:00 grep --color=auto nginx
[root@GOLANG conf]#  nginx -s reload   重启nginx,root不改变,worker改变
[root@GOLANG conf]# ps aux|grep nginx
root       1897  0.0  0.0  46372  2016 ?        Ss   21:05   0:00 nginx: master process nginx
wjz        2028  0.0  0.0  46812  2048 ?        S    21:33   0:00 nginx: worker process
wjz        2029  0.0  0.0  46812  2048 ?        S    21:33   0:00 nginx: worker process
wjz        2030  0.0  0.0  46812  2048 ?        S    21:33   0:00 nginx: worker process
root       2032  0.0  0.0 112824   988 pts/0    S+   21:33   0:00 grep --color=auto nginx
[root@GOLANG conf]# 
配置文件传参
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值