当前位置: 首页 > news >正文

企业架构LNMP学习笔记5

Nginx:

常见用法:

1)web服务器软件  httpd http协议

同类的web服务器软件:apache Nginx(俄罗斯)IIS(微软)lighttpd(德国)

2)代理服务器 反向代理:

3)邮箱代理服务器 IMAP、POP3、SMTP

4)负载均衡功能:LB、loadbalance

Nginx的特点:

1)高可靠:稳定性 master进程 管理调度请求分发到哪一个worker,worker进程响应请求,一个master进程,多个worker进程。

2)热部署:1)平滑升级 (热升), 2)可以快速重载配置。

3)高并发:可以同时响应更多的请求,实践epoll模型IO复用调用的模型 几万并发。

4)响应快:尤其在处理静态文件上,响应速度很快。

5)低消耗:CPU和内存,1万个请求,内存2-3M。

6)分布式支持:反向代理 七层负载均衡 还能做缓存。

nginx安装脚本,同时需要上传nginx的1.24.0的版本。

#!/bin/bash
#编译安装Nginx
nginx_install(){
#创建软件运行用户
`id www` &>>/dev/null
if [ $? -ne 0 ];thenuseradd -s/sbin/nologin -M www
fi
#安装依赖
yum -y install pcre-devel zlib-devel openssl-devel
#编译安装
cd /root/soft
tar xvf nginx-1.24.0.tar.gz
cd nginx-1.24.0
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module && make && make install
}
#脚本开始时间
start_time=`date +%s`
#执行的脚本代码
nginx_install
#脚本结束时间
end_time=`date +%s`
#脚本执行花费时间
const_time=$((end_time-start_time))
echo 'Take time is: '$const_time's'

# nginx启动:
./usr/local/nginx/sbin/nginx
[root@server01 sbin]# ./nginx -h
nginx version: nginx/1.24.0
Usage: nginx [-?hvVtTq] [-s signal] [-p prefix][-e filename] [-c filename] [-g directives]Options:-?,-h         : this help-v            : show version and exit-V            : show version and configure options then exit-t            : test configuration and exit-T            : test configuration, dump it and exit-q            : suppress non-error messages during configuration testing-s signal     : send signal to a master process: stop, quit, reopen, reload-p prefix     : set prefix path (default: /usr/local/nginx/)-e filename   : set error log file (default: logs/error.log)-c filename   : set configuration file (default: conf/nginx.conf)-g directives : set global directives out of configuration file

一般主要使用:

-s:参数控制管理nginx参数;

-V:参数查看nginx开启的模块和编译参数;

-t:检测配置文件是否有错误。

其中有个重开日志reopen的功能,需要学习下。

我们想要配置跟之前服务器一样的配置参数,可以通过-V查看到配置参数。做服务器迁移。

然后添加到系统服务:

vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx web service
Documentation=http://nginx.org/en/docs/
After=network.target[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true[Install]
WantedBy=default.target
chmod 755 /usr/lib/systemd/system/nginx.service
启动: systemctl start nginx
停止: systemctl stop nginx
重启: systemctl restart nginx
重新加载配置文件: systemctl reload nginx
查看nginx状态: systemctl status nginx
开机启动: systemctl enable nginx

另外有个记录:

http://www.lryc.cn/news/150058.html

相关文章:

  • Idea安装免注册版ChatGPT
  • git操作
  • 9 | 求出不同性别和不同科目的学生平均分数
  • Java如何发起http的get请求的实现
  • webRtc 示例
  • 【RabbitMQ】服务启动成功,无法访问localhost:15672(RabbitMQ Management)
  • 【操作记录】pytorch_geometric安装方法
  • EventSystem 事件系统
  • 2.2 Vector<T> 动态数组(模板语法)
  • dockerfile 例子(二)
  • openssh---Windows下git安装配置gitlab
  • vscode宏键绑定
  • 外贸企业如何借助CRM提升企业发展?
  • 初步了解ES
  • Linux基础(三)
  • python函数调用的四种方式
  • 如何将两个pdf合并成一个?pdf合并技巧分享
  • qt : day 3
  • flutter高德地图大头针
  • 【线性代数】矩阵求导的本质与分子布局、分母布局的本质(矩阵求导——本质篇)
  • 快速了解状态管理库Pinia及其使用方法
  • scratch绘制同心圆 2023年5月中国电子学会图形化编程 少儿编程 scratch编程等级考试四级真题和答案解析
  • 【LeetCode】3. 无重复字符的最长子串
  • 苹果macOS 14开发者预览版Beta 7发布 新增超过100款视频壁纸和屏保
  • Redis 7 第五讲 事务、管道、发布订阅 过渡篇
  • [SpringBoot3]视图技术Thymeleaf
  • wangluobiancheng
  • 大数据之hadoop入门
  • 浅谈多人游戏原理和简单实现。
  • 活动预告 | 龙智、紫龙游戏与JFrog专家将出席龙智DevSecOps研讨会,探讨企业大规模开发创新