天天看点

PHP的本地Session信息

3.1 问题

通过Nginx调度器负载后端两台Web服务器,实现以下目标:

  1. 部署Nginx为前台调度服务器
  2. 调度算法设置为轮询
  3. 后端为两台LNMP服务器
  4. 部署测试页面,查看PHP本地的Session信息

3.2 方案

使用4台RHEL7虚拟机,其中一台作为Nginx前端调度器服务器(eth0:192.168.4.5,eth1:192.168.2.5)、两台虚拟机部署为LNMP服务器,分别为Web1服务器(192.168.2.100)和Web2服务器(192.168.2.200),另外一台作为测试用的Linux客户机(192.168.4.100),拓扑如图-2所示。

PHP的本地Session信息

步骤一:部署后端LNMP服务器相关软件

步骤二:启动LNMP服务器相关的服务

步骤三:部署前端Nginx调度服务器

[[email protected] ~]# vim  /usr/local/nginx/conf/nginx.conf

35     upstream webs  {

 36         server 192.168.2.100:80;

 37         server 192.168.2.200:80;

 38   }

47         location / {

 48            proxy_pass http://webs;

 49             root   html;

 50             index  index.php index.html index.htm;

 51         }

:wq

开启后端服务器:

[[email protected] ~]# systemctl  restart httpd

[[email protected] ~]# systemctl  restart  httpd

步骤四:测试环境是否配置成功

1)浏览器访问测试页面验证。

[[email protected] ~]# firefox  http://192.168.4.5/test.php

[[email protected] ~]# curl http://192.168.4.5/index.html

192.168.2.100

[[email protected] ~]# curl http://192.168.4.5/index.html

192.168.2.200

[[email protected] ~]# curl http://192.168.4.5/index.html

192.168.2.100

继续阅读