First, install the JDK7
1. Query the installed JDK
Rpm-qa|grep JDK
2. Uninstall the JDK that is already installed
rpm-e--nodeps * * * * * * * * ...
3. Upload the installation file jdk-7u79-linux-x64.rpm to/usr/java
Cd/usr/java
4. Installation
RPM-IVH jdk-7u79-linux-x64.rpm
5. Edit Profile Add the following three lines
Vim/etc/profile
Export java_home=/usr/java/jdk1.7.0_79
Export path= $PATH: $JAVA _home/bin: $JAVA _home/jre/bin
Export classpath=.: $JAVA _home/lib: $JAVA _home/jre/lib: $CLASSPATH
Export PATH USER LOGNAME MAIL HOSTNAME histsize Histcontrol
6. Make the configuration effective immediately
Source/etc/profile
Second, install Nginx
1. Create a new file
Touch/etc/yum.repos.d/nginx.repo
2. Edit New File
Vim/etc/yum.repos.d/nginx.repo
3. Copy the following contents in
[Nginx]
Name=nginx Repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
Gpgcheck=0
Enabled=1
4. Perform Yum installation
Yum-y Install Nginx
5. Start Nginx
Service Nginx Start
6. Test Nginx
Curl 127.0.0.1
Iii. installation of Redis
1. Installing TCL support
Yum install Tcl
2. Installing GCC Support
Yum install-y gcc g++ gcc-c++ make
3. Download Redis
wget http://download.redis.io/releases/redis-2.8.16. tar.gz
4. Unzip
tar xzf redis-2.8.16.tar.gz
5. Enter the catalogue
CD redis-2.8.16
6. Installation
Make
Make Test
Make install
7. Edit the redis.conf file and copy it to the ETC directory
Vim redis.conf
Modify Daemonize no change to Yes
CP Redis.conf/etc
8. Self-priming
Go to Catalog
CD/ETC/INIT.D
Create a file
Touch Redis
Edit File
Vim Redis
Copy the following to the file save exit
##########################
#chkconfig: 2345 10 90
#description: Start and Stop Redis
Path=/usr/local/bin:/sbin:/usr/bin:/bin
redisport=6379
Exec=/usr/local/bin/redis-server
Redis_cli=/usr/local/bin/redis-cli
Pidfile=/var/run/redis.pid
C/etc/redis.conf "
Case "$" in
Start
If [-F $PIDFILE]
Then
echo "$PIDFILE exists, process is already running or crashed"
Else
echo "Starting Redis server ..."
$EXEC $CONF
Fi
If ["$?" = "0"]
Then
echo "Redis is running ..."
Fi
;;
Stop
if [!-F $PIDFILE]
Then
echo "$PIDFILE does not exist, process was not running"
Else
pid=$ (Cat $PIDFILE)
echo "Stopping ..."
$REDIS _cli-p $REDISPORT SHUTDOWN
While [-X ${pidfile}]
Do
echo "Waiting for Redis to shutdown ..."
Sleep 1
Done
echo "Redis stopped"
Fi
;;
Restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage:/etc/init.d/redis {start|stop|restart|force-reload}" >&2
Exit 1
Esac
##############################
9. Modify Permissions
chmod +x/etc/init.d/redis
10. Start the Redis service
Service Redis Start
11. Enter REDIS-CLI to test
Set Redis Hello,redis
+ok
Get Redis
$11
Hello,redis
Four, nginx configuration
1. Forget where Nginx is installed
Whereis Nginx
2. Cut into the table of contents
Cd/etc/nginx
3. Edit the configuration file
Upstream www.test.com{
Ip_hash;
Server localhost:8080;
Server localhost:9080;
}
server {
Listen 80;
server_name www.test.com;
CharSet Utf-8;
Location/{
Proxy_pass http://www.test.com;
Proxy_set_header X-real-ip $remote _addr;
Client_max_body_size 100m;
Proxy_connect_timeout 16;
Proxy_read_timeout 16;
Proxy_send_timeout 16;
}
}
4. Reload
Nginx-s Reload
5. Modify the Hosts file
Vim/etc/hosts
New
127.0.0.1 www.test.com
V. Run two Tomcat configurations on the same server
1. Modify Profile
Vim/etc/profile
Add the following:
catalina_base=/mnt/apache-tomcat-01 "TOMCAT1 path"
Catalina_home=/mnt/apache-tomcat-01
Export Catalina_base Catalina_home
catalina_2_base=/mnt/apache-tomcat-02 "Tomcat2 path"
catalina_2_home=/mnt/apache-tomcat-02
Export Catalina_2_base Catalina_2_home
Tomcat_home=/mnt/apache-tomcat-01
Export Tomcat_home
tomcat_2_home=/mnt/apache-tomcat-02
Export Tomcat_2_home
2. Make configuration effective
Source/etc/profile
3. Copy Tomcat two copies, one copy without modification, and the other requires the following modifications
Modify server.xml
Port: 8005->9005
Port : 8080->9080
8009->9009
Modify startup.sh and shutdown.sh add the following:
Export java_home=/usr/java/jdk1.7.0_79
Export ath= $PATH: $JAVA _home/bin
Export Classpath= $JAVA _home/lib
Export Catalina_home= $CATALINA _2_home
Export catalina_base= $CATALINA _2_base
Vi. Session Sharing
Added in two Tomcat Content.xml
< span="">
host= "localhost"
Port= "6379"
database= "0"
Maxinactiveinterval= "/>"
Seven, testing
Create a project in the page output SessionID
Refreshes the page, SessionID remains unchanged, indicating a successful configuration
You can go to the REDIS-CLI console and use the keys * to see the SessionID on the page.
Note: This article integrates the information distributed on the Internet, only for the convenience of help to the needy, if there is a violation of your content, please contact me, thank you.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the CENTOS65 load balancing nginx session sharing Redis, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.