先放个链接,万一有人关注呢
↓ ↓ ↓ ↓ ↓
应用介绍
Nginx是一款高性能的Web服务器和反向代理服务器,最初由俄罗斯的程序设计师Igor Sysoev开发。Nginx使用事件驱动的异步非阻塞处理方式,可以处理大量的并发连接,具有较高的性能表现。
环境部署示例
这里写一个部署脚本,用于部署NginxWeb与Nginx负载均衡
#!/bin/bash# 生成SSH密钥-t rsa# 将公钥拷贝到web服务器<web_server1_ip><web_server2_ip># 安装和配置Nginx负载均衡器yum install -y nginxsystemctl enable nginxcp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bakcat << EOF > /etc/nginx/nginx.confuser nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;events {worker_connections 1024;}http {upstream myapp1 {server <web_server1_ip>:80;server <web_server2_ip>:80;}server {listen 80;server_name <load_balancer_ip>;location / {proxy_pass http://myapp1;}}}systemctl start nginx# 安装和配置Nginx web服务器ssh <web_server1_ip> "yum install -y nginx"ssh <web_server1_ip> "systemctl enable nginx"ssh <web_server1_ip> "cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak"ssh <web_server1_ip> "cat << EOF > /etc/nginx/nginx.confuser nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;events {worker_connections 1024;}http {server {listen 80;server_name <web_server1_ip>;root /var/www/html;index index.html;}}EOF"ssh <web_server1_ip> "systemctl start nginx"ssh <web_server2_ip> "yum install -y nginx"ssh <web_server2_ip> "systemctl enable nginx"ssh <web_server2_ip> "cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak"ssh <web_server2_ip> "cat << EOF > /etc/nginx/nginx.confuser nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;events {worker_connections 1024;}http {server {listen 80;server_name <web_server2_ip>;root /var/www/html;index index.html;}}EOF"ssh <web_server2_ip> "systemctl start nginx"
结束!如有不足之处,欢迎指正!
我们的组织在这里:


原文作者:运维book思议;如有侵权,请联系管理员删除。