nginx+tomcat7+redis session共享
来自: http://my.oschina.net/39605380/blog/616394
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共享
同时启动2个节点刷新页面