nginx+tomcat7+redis session共享
2016-02-17 15:56
555 查看
1.安装nginx
wget http://sourceforge.net/settings/mirror_choices?projectname=pcre&filename=pcre/8.32/pcre-8.32.tar.gz
nginx download:
wget http://nginx.org/download/nginx-1.6.2.tar.gz
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl-devel
unzip nginx-goodies-nginx-sticky-module-ng.zip -d /usr/local/
groupadd -r nginx
useradd -s /sbin/nologin -g nginx -r nginx
tar zxvf pcre-8.32.tar.gz
cd pcre-8.32
./configure --prefix=/usr/local/pcre
make
make install
tar zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2
./configure --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --with-http_gzip_static_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.32
make
make install
修改nginx配置文件
vi /etc/nginx/nginx.conf
添加以下内容:
server {
listen 80 default_server;
server_name 172.25.73.120;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
# redirect server error pages to the static page /40x.html
error_page 404 /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
2.安装tomcat
tar xzf apache-tomcat-7.0.59.tar.gz
mv apache-tomcat-7.0.59 tomcat
启动tomcat
./ tomcat/bin/ catalina.sh start
修改contest.xml文件
<Context>
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="localhost"
port="6379"
database="0"
maxInactiveInterval="60"/>
</Context>
tomcat需要的jar包,下载地址 http://down.51cto.com/data/2173531
commons-pool2-2.2
jedis-2.5.2
tomcat-redis-session-manage-tomcat7
上面的3个jar放到 tomcat/lib/ 目录下
3.安装redis
tar -zxf redis-2.6.16.tar.gz
cd redis-2.6.16
make
make install
mv redis-2.6.16 /usr/local/redis
cd /usr/local/redis/
mkdir conf
启动redis
/usr/local/redir/src/redis-server /usr/local/redir/redis.conf &
测试session共享
![](http://static.oschina.net/uploads/space/2016/0217/155407_Nxhj_1174243.png)
同时启动2个节点刷新页面
![](http://static.oschina.net/uploads/space/2016/0217/155502_5UYW_1174243.png)
![](http://static.oschina.net/uploads/space/2016/0217/155502_aRDr_1174243.png)
wget http://sourceforge.net/settings/mirror_choices?projectname=pcre&filename=pcre/8.32/pcre-8.32.tar.gz
nginx download:
wget http://nginx.org/download/nginx-1.6.2.tar.gz
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl-devel
unzip nginx-goodies-nginx-sticky-module-ng.zip -d /usr/local/
groupadd -r nginx
useradd -s /sbin/nologin -g nginx -r nginx
tar zxvf pcre-8.32.tar.gz
cd pcre-8.32
./configure --prefix=/usr/local/pcre
make
make install
tar zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2
./configure --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --with-http_gzip_static_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.32
make
make install
修改nginx配置文件
vi /etc/nginx/nginx.conf
添加以下内容:
server {
listen 80 default_server;
server_name 172.25.73.120;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
# redirect server error pages to the static page /40x.html
error_page 404 /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
2.安装tomcat
tar xzf apache-tomcat-7.0.59.tar.gz
mv apache-tomcat-7.0.59 tomcat
启动tomcat
./ tomcat/bin/ catalina.sh start
修改contest.xml文件
<Context>
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="localhost"
port="6379"
database="0"
maxInactiveInterval="60"/>
</Context>
tomcat需要的jar包,下载地址 http://down.51cto.com/data/2173531
commons-pool2-2.2
jedis-2.5.2
tomcat-redis-session-manage-tomcat7
上面的3个jar放到 tomcat/lib/ 目录下
3.安装redis
tar -zxf redis-2.6.16.tar.gz
cd redis-2.6.16
make
make install
mv redis-2.6.16 /usr/local/redis
cd /usr/local/redis/
mkdir conf
启动redis
/usr/local/redir/src/redis-server /usr/local/redir/redis.conf &
测试session共享
![](http://static.oschina.net/uploads/space/2016/0217/155407_Nxhj_1174243.png)
同时启动2个节点刷新页面
![](http://static.oschina.net/uploads/space/2016/0217/155502_5UYW_1174243.png)
![](http://static.oschina.net/uploads/space/2016/0217/155502_aRDr_1174243.png)
![](http://static.oschina.net/uploads/space/2016/0217/155502_jzMl_1174243.png)
相关文章推荐
- java-模拟tomcat服务器
- i-jetty环境搭配与编译
- nginx代理指定目录
- 实现单Tomcat多Server配置
- 生产环境下的Tomcat配置
- 访问Nginx发生SSL connection error的一种情况
- redis安装问题小结
- Linux部署Tomcat服务器
- Nginx+Naxsi部署专业级Web应用防火墙
- jenkins------结合maven将svn项目自动部署到tomcat下
- 如何搞定tomcat这只喵~
- CentOS 6.2实战部署Nginx+MySQL+PHP
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Nginx 学习笔记(一)
- 网站502与504错误分析