CentOS 7虚拟机下模拟实现nginx负载均衡
以CentOS 7为例,我们模拟实现nginx来处理静态资源,apache来处理php
1.首先我们来安装nginx
# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.建立YUM仓库
# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
3.安装nginx
yum install nginx
4.启动nginx并设置为开机启动
nginx 启动nginx 如果机器上面已经安装了apache此次会报错。我们需要修改端口
systemctl enable nginx 开机启动
5.修改nginx的配置文件,设置一个新端口
cd /etc/nginx --进入nginx目录
vi nginx.conf --修改配置
# include /etc/nginx/conf.d/*.conf; 注释掉此行,为了避免载入conf.d目录下的配置
server {
listen 88 ; 重新设置端口
# server_name test.com;
location /
{
root /usr/share/nginx/html; 默认目录
index index.html index.htm;
}
location ~ \.php$ { PHP路由转向规则
proxy_pass http://192.168.0.101:80;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ { PHP处理文件及目录(本机apache)
root /var/www/html;
fastcgi_pass 192.168.0.101:80;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
这样html资源就留在了localhost:88,php资源就转向192.168.0.101
CentOS 7虚拟机下模拟实现nginx负载均衡的更多相关文章
- Net分布式系统之二:CentOS系统搭建Nginx负载均衡
一.关于CentOS系统介绍 CentOS(Community Enterprise Operating System,中文意思是:社区企业操作系统)是Linux发行版之一,它是来自于Red Hat ...
- 手把手教你玩转nginx负载均衡(二)----安装虚拟机操作系统
引言 在上一篇,我们组装好了虚拟机的硬件部分,那么现在我们就要把操作系统装上了,既然是服务器,那么安装linux操作系统是个比较好的选择,如果你喜欢的话,安装windows也是没有任何问题的 我这里选 ...
- CentOS中nginx负载均衡和反向代理的搭建
1: 修改centos命令行启动(减少内存占用): vim /etc/inittab :initdefault: --> 修改5为3 若要界面启动使用 startx 2:安装jdk )解压:jd ...
- Nginx知多少系列之(六)Linux下.NET Core项目负载均衡
目录 1.前言 2.安装 3.配置文件详解 4.工作原理 5.Linux下托管.NET Core项目 6.Linux下.NET Core项目负载均衡 7.负载均衡策略详解 8.Linux下.NET C ...
- centos 6.5下安装mysql+nginx+redmine 3.1.0 笔记
centos 6.5下安装mysql+nginx+redmine 3.1.0 笔记 目录[-] 过程 1.安装RVM 2.利用rvm安装 Ruby 1.9.3 并设为默认 3.安装rails 4.安装 ...
- linux下nginx负载均衡部署
nginx负载均衡部署 Nginx("engine x") 是一个高性能的 HTTP 和 反向代理 server,也是一个 IMAP/POP3/SMTP 代理server. Ngi ...
- nginx Win下实现简单的负载均衡(2)站点共享Session
快速目录: 一.nginx Win下实现简单的负载均衡(1)nginx搭建部署 二.nginx Win下实现简单的负载均衡(2)站点共享Session 三.nginx Win下实现简单的负载均衡(3) ...
- nginx Win下实现简单的负载均衡(1)nginx搭建部署
快速目录: 一.nginx Win下实现简单的负载均衡(1)nginx搭建部署 二.nginx Win下实现简单的负载均衡(2)站点共享Session 三.nginx Win下实现简单的负载均衡(3) ...
- 用nginx进行同一个服务器下多域名的负载均衡配置
用nginx进行同一个服务器下多域名的负载均衡配置 Nginx进行http负载均衡的模块是upstream Upstream可以进行多个配置,这样的话可以灵活的配置站点,但是注意的是upstream后 ...
随机推荐
- 向内存0:200~0:23f依次传送数据0~3fh
只能用字节为单位传送了. assume cs:sad sad segment start: mov ax, 20h mov ds, ax mov cx, 40h s: mov [bx], bl inc ...
- VMvare克隆复制多个操作系统
目的:完成linux的双机和集群实验 2016-12-06 在网上查找了一些资料现整理如下,以供之后查看和帮助他人. 注意事项: 1.关闭源虚拟机的电源: 操作很简单 选择完整创建 输入源克隆机的用户 ...
- 关于Cookie的 工具类
import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; ...
- Examples of complexity pattern
O(1):constant - the operation doesn't depend on the size of its input, e.g. adding a node to the tai ...
- ubuntu 安装mongodb
安装 mongodb sudo apt-get install mongodb 创建目录(放在单独文件夹中) mkdir data/aa 在目录外面启动,端口为27017 mongod -dbpath ...
- Servlet中The requested resource is not available错误
自己为了测试servlet,用MyEclipse2015写了一个简单的登录程序. 1.登录页面index.jsp. <%@ page language="java" impo ...
- 【POJ3621】Sightseeing Cows
Sightseeing Cows Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8331 Accepted: 2791 ...
- 0x00linux32位汇编初入--前期准备
0x00汇编初入--前期准备 一.汇编工具 在linux平台下常用的编译器为as,连接器为ld,使用的文本编辑器为vim,汇编语法为att 以下是一些工具: addr2line 把地址转换为文件名和行 ...
- 安卓,支付宝app登录时,提示 服务器安全证书已过期或不可信任,请问怎么解决
安卓,支付宝app登录时,提示 服务器安全证书已过期或不可信任,请问怎么解决 请把手机时间调成当前时间.
- 解决ideviceinstaller未安装的问题
在Mac上,使用Appium时提示: Could not initialize ideviceinstaller; make sure it is installed and works on you ...