Nginx安装

在线自动生成nginx配置文件

https://www.digitalocean.com/community/tools/nginx?global.app.lang=zhCN

可以自由选择所需的应用,生成nginx配置作为参考。

nginx企业用它干啥

```

1.提供静态页面展示,网页服务
2.提供多个网站、多个域名的网页服务

3.提供反向代理服务(结合动态应用程序)

4.提供简单资源下载服务(密码认证) ftp服务

5.用户行为分析(日志功能)

```

yum安装

1. 配置官网yum源,一键安装即可

[root@web]#cat > /etc/yum.repos.d/nginx.repo << 'EOF'
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
EOF

2.清空yum源,安装最新版nginx
[root@web]#yum clean all

[root@web]#yum install nginx -y

3.查看PATH变量
[root@web]#which nginx
/usr/sbin/nginx

[root@web]#ll /usr/sbin/nginx
-rwxr-xr-x 1 root root 1377720 Nov 16 2021 /usr/sbin/nginx

[root@web]#nginx -V
nginx version: nginx/1.20.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017

4、默认文件路径

  /etc/nginx/nginx.conf  主配置文件
  /var/log/nginx/access.log 日志文件
  /usr/share/nginx/html/index.html 网站文件
  /usr/sbin/nginx  执行程序

 

 

nginx管理命令

nginx -t # 检测nginx.conf语法
nginx -s reload # 重新读取nginx.conf
nginx -s stop # 停止nginx kill -15 nginx

nginx -c nginx.conf的路径 #指定用哪个配置文件

nginx # 默认是直接运行,前提是当前机器没运行nginx

# 不能多次执行nginx二进制命令

#nginx -s reload是给master进程发信号,重新读取配置信息,导致worker重新生成,因此worker-pid发生了变化

#但是master进程id不变化的(包工头,一直没变,更换了手底下的干活的工人)

 

#你通过yum安装的nginx请你用systemctl去管理

[root@web-8 ~]#systemctl start nginx 启动nginx

[root@web-8 ~]#systemctl status nginx  查看状态

[root@web-8 ~]#systemctl reload nginx  重新加载配置文件,worker变化,master不变

[root@web-8 ~]#systemctl restart nginx  重启nginx ,整个nginx进程变化

 

# 用什么命令启动的,就用什么方式去管理该进程

#关闭防火墙systemctl stop firewalld.service

 

posted @ 2023-05-31 11:24  QUDE  阅读(9)  评论(0编辑  收藏  举报