Nginx and tomcat configuration in CentOs6 (Lite version)

Source: Internet
Author: User


Server Load balancer and session sharing are implemented. 1. jdk installation configuration: jdk version: the jdk-6u31-linux-i586.binmkdir/usr/java copies the downloaded jdk-6u31-linux-i586.bin to the/usr/java directory for cp jdk-6u31-linux-i586.bin/usr/java installation. jdk-6u31-linux-i586.bin
After installation, add the following configuration environment variable: vi/etc/profile at the end of the file: export JAVA_HOME =/usr/java/jdk1.6.0 _ 31 export CLASSPATH =.: $ JAVA_HOME/jre/lib/rt. jar: $ JAVA_HOME/lib/tools. jarexport PATH = $ PATH: $ JAVA_HOME/bin to make the environment variable take effect immediately www.2cto.com source/etc/profile
2, tomcat installation configuration: tomcat version: apache-tomcat-6.0.35.tar.gztomcat does not need to install, unzip it to use, directory for usr/tomcattar-zxvf apache-tomcat-6.0.35.tar.gz in this configuration of two tomcat, tomcat1 is the following Configuration: <Server port = "8005" shutdown = "SHUTDOWN"> <Connector port = "8080" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443"/> <connector port = "8009" protocol = "AJP/1.3" redirectPort = "8443"/> <Engine name = "Catalina" defaultHost = "localhost" jvmRoute = "tomcat2">
Tomcat2 is configured as follows: <Server port = "9005" shutdown = "SHUTDOWN"> <Connector port = "8090" protocol = "HTTP/1.1" connectionTimeout = "20000" redirectPort = "8443"/> <connector port = "9009" protocol = "AJP/1.3" redirectPort = "8443"/> <Engine name = "Catalina" defaultHost = "localhost" jvmRoute = "tomcat1">
3. ngnix installation configuration ngnix version: the module of the nginx-1.0.10.tar.gzngnix needs the support of some other third-party libraries. The Gzip module requires the zlib library Rewrite module and the pcre Library Ssl function. before using the openssl library, install the corresponding third-party library yum-y install gcc-c ++ autoconf automakeyum-y install. zlib-devel openssl opsenssl-devel pcre-develwget http://nginx-upstream-jvm-route.googlecode.com/files/nginx-upstream-jvm-route-0.1.tar.gztar xzvf nginx-upstream-jvm-route-0.1.tar.gz // configure the decompression path for jvm_route, mainly to find jvm_route.patchpatch-p0 </usr/local/src/nginx_upstream_jvm_route/jvm_route.patchtar-zxvf nginx-1.0.10.tar.gzcd. /configure -- prefix =/usr/local/nginx -- add-module =/usr/local/src/nginx_upstream_jvm_routemakemake install
Next, configure nginx. Its configuration file:/usr/local/nginx/conf/nginx. modify conf as follows: worker_processes 1; error_log logs/error. log crit; pid logs/nginx. pid; www 2cto.com events {use epollworker_connections 1024;} http {include mime. types; default_type application/octet-stream; sendfile on; tcp_nopush on; limit 65; upstream localhost {server 127.0.0.1: 8080 srun_id = paiat1 weight = 1; server 127.0.0.1: 8090 srun_id = Limit w at1 Eight = 3; jvm_route $ restore reverse;} server {listen 80; server_name localhost; location/{proxy_redirect off; proxy_set_header Host $ host; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for; proxy_pass http: // localhost;} error_page 500 502 503 504/50 x.html; location =/50x.html {root html ;}}} start nginx and tomcat for testing/usr/local/tomcat1/bin/startu P. sh/usr/local/tomcat2/bin/startup. sh/usr/local/nginx/sbin/nginx-t // test whether the nginx configuration file is correct, if the following command is correctly executed to start/usr/local/nginx/sbin/nginx www.2cto.com, modify index.html under tomcat1 and tomcat2, and add tomcat1 and tomcat2. Then access: http: // localhost
You can check which tomcat is accessed. After multiple accesses, you can find that the ratio of tomcat1 to tomcat2 is about 1: 2 PS: This configuration wastes a lot of time, the main reason is that you want to add all the parameters at the beginning, and you don't know what is added at the end of the result, which breaks up the relationship between them and has no clue. Finally, I did it again on windows, and it was done soon. Then I did it again on centos6, without any major obstacles.
Therefore, when learning some strange things in the future, do not ask for more. First, clarify its basic things and what functions are needed before you can add them slowly. Remember to ask for more at the beginning, as a result, too many unfamiliar things make a mess. Author yl1003

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.