一、环境介绍
1.本次实验共3台虚拟机(rhel6.2-64)
192.168.232.147(nginx)
192.168.232.154(tomcat)
192.168.232.155(tomcat)
2.安装并配置JDK
3.配置相关环境变量(profile,hosts)
4.准备好一个web项目,以便用于测试是否负载均衡,本次实验用一以前写的权限管理的模块
二、安装配置tomcat
1.在192.168.232.154,192.168.232.155机器安装tomcat
2.下载一个linux版本的apache-tomcat-7.0.64.tar.gz解压即可用
3.在
<context path="" docbase="/root/webapps/permission" reloadable="false"></context>
4.创建/root/webapps目录,然后把permission这个web项目放到该目录下,启动tomcat,访问
http://192.168.232.154:8080/ , http://192.168.232.154:8080/ 可以访问到permission项目的首页
三、安装配置Nginx
1.下载nginx-1.2.6.tar.gz 并解压放到指定的目录下
2.确保nginx编译所具备的运行环境
3.安装pcre-devel openssl openssl-devel
(1)配置本地yum,使得yum安装时能找到安装包
(2)安装:yum -y install pcre-devel openssl openssl-devel
4.创建www用户:useradd www
5.准备编译安装环境
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
6.编译安装,进到nginx解压的根目录:cd /root/app/nginx-1.2.6
make && make install
7.检查nginx安装是否成功
[root@storm1 nginx-1.2.6]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
8.访问nginx默认主页:http://192.168.232.147:80/,可以看到nginx欢迎主页面
到此Nginx安装完毕
四、配置nginx+tomcat集成,其实只需配置nginx,tomcat不用动
1.进到安装指定的目录:/usr/local/nginx,把nginx.conf简单的改成如下
user www www; worker_processes 1; pid /usr/local/nginx/logs/nginx.pid; events { use epoll; worker_connections 1024; } http { include mime.types; default_type application/octet-stream; include /usr/local/nginx/conf/proxy.conf; sendfile on; tcp_nopush on; keepalive_timeout 65; log_format $upstream_addr $status $request_time $time_local $remote_user $http_user_agent; upstream panguoyuan.com { server 192.168.232.154:8080; server 192.168.232.155:8080; } server{ listen 80; server_name panguoyuan.com; location / { proxy_pass http://panguoyuan.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } }
2.在192.168.232.147机器上的hosts如下
[root@storm1 conf]# cat /etc/hosts
192.168.232.147 storm1
192.168.232.154 storm2
192.168.232.155 storm3
192.168.232.147 panguoyuan.com
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了nginx+tomcat负载均衡,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

本篇文章给大家带来了关于nginx的相关知识,其中主要介绍了nginx拦截爬虫相关的,感兴趣的朋友下面一起来看一下吧,希望对大家有帮助。

高并发系统有三把利器:缓存、降级和限流;限流的目的是通过对并发访问/请求进行限速来保护系统,一旦达到限制速率则可以拒绝服务(定向到错误页)、排队等待(秒杀)、降级(返回兜底数据或默认数据);高并发系统常见的限流有:限制总并发数(数据库连接池)、限制瞬时并发数(如nginx的limit_conn模块,用来限制瞬时并发连接数)、限制时间窗口内的平均速率(nginx的limit_req模块,用来限制每秒的平均速率);另外还可以根据网络连接数、网络流量、cpu或内存负载等来限流。1.限流算法最简单粗暴的

实验环境前端nginx:ip192.168.6.242,对后端的wordpress网站做反向代理实现复杂均衡后端nginx:ip192.168.6.36,192.168.6.205都部署wordpress,并使用相同的数据库1、在后端的两个wordpress上配置rsync+inotify,两服务器都开启rsync服务,并且通过inotify分别向对方同步数据下面配置192.168.6.205这台服务器vim/etc/rsyncd.confuid=nginxgid=nginxport=873ho

nginx php403错误的解决办法:1、修改文件权限或开启selinux;2、修改php-fpm.conf,加入需要的文件扩展名;3、修改php.ini内容为“cgi.fix_pathinfo = 0”;4、重启php-fpm即可。

跨域是开发中经常会遇到的一个场景,也是面试中经常会讨论的一个问题。掌握常见的跨域解决方案及其背后的原理,不仅可以提高我们的开发效率,还能在面试中表现的更加

linux版本:64位centos6.4nginx版本:nginx1.8.0php版本:php5.5.28&php5.4.44注意假如php5.5是主版本已经安装在/usr/local/php目录下,那么再安装其他版本的php再指定不同安装目录即可。安装php#wgethttp://cn2.php.net/get/php-5.4.44.tar.gz/from/this/mirror#tarzxvfphp-5.4.44.tar.gz#cdphp-5.4.44#./configure--pr

nginx部署react刷新404的解决办法:1、修改Nginx配置为“server {listen 80;server_name https://www.xxx.com;location / {root xxx;index index.html index.htm;...}”;2、刷新路由,按当前路径去nginx加载页面即可。

nginx禁止访问php的方法:1、配置nginx,禁止解析指定目录下的指定程序;2、将“location ~^/images/.*\.(php|php5|sh|pl|py)${deny all...}”语句放置在server标签内即可。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

Dreamweaver CS6
视觉化网页开发工具

禅工作室 13.0.1
功能强大的PHP集成开发环境