CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATHsLAS.HO+Som; USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
[root@localhost java]# source /etc/profile
[root@localhost java]# javaversion
[root@localhost java]# javaversion. Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
二、安裝 Tomcat下載:http://tomcat.apache.org/ # tar zxvf apache-tomcat-7.0.26.g.gz -C /tar/c /src/# cp -rf apache-tomcat-7.0.26 /usr/local/tomcat# cp -rf apache-tomcat-7.0.26 /usr/local/tomcat# cp -rf apache-tomcat-7.0.26 /usr/local/tomcat1將第一個 TOMCAT安裝在/usr/local/tomcat# cd /usr/local/tomcat
# vi /etc/profile+ 在PATH後面加入:$CATALINA_HOME/lib
export TOMCAT_HOME=/usr/local/tomcatexport CATALINA_HOME/usr/ $PATH:$CATALINA_HOME/libexport CLASSPATH=$CLASSPATH:$CATALINA_HOME/common/lib/servlet.jar #vi /etc/profile在
CLASSPATH後面加上$TOMCAT_2_HOME/common/lib/servlet.jar
在
PATH後面加上/ tomcat1export CATALINA_1_HOME=/usr/local/tomcat1export CATALINA_1_BASE=/usr/local/tomcat1export PATH=$PATH:$CATALINA_1_HOME/lib. 保存退出:wq使環境變數生效#source /etc/profile 修改TOMCAT設定檔vi /usr/local/tomcat1/conf/server.xml(如果兩個tomcat不在同一台機器可以不用修改連接埠)將下列內容 " shutdown="SHUTDOWN">... .../>= UTDOWN ">... 修改TOMCAT設定啟動檔案/usr/local/tomcat1/bin/startup.sh在exec上新增以下內容在exec上新增以下內容 JRE_HOME=/usr/java/jdk1.7.0_03/jreexport CLASSPATH=$JAVA_HOME/libexport PATH=$JAVA_HOME/bin:$PATHexport PATH=$JAVA_HOME/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATHexport PATH=$JAVA_HOME/bin:$PATHcom JAVA_HOME/bin的,在啟動時會報錯誤%export CATALINA_HOME=$CATALINA_2_HOMEexport CATALINA_HOME=$CATALINA_2_HOMEexport CATALINA_BASE=$CATALINA_2_BASE元(c 在exec上加入以下內容export JAVA_HOME=/usr/local/java/jdk1.7.0_03export JRE_HOME=/usr//////223_export /libexport PATH=$JAVA_HOME/bin:$PATHexport CATALINA_HOME=$CATALINA_2_HOMEexport /usr/local/tomcat1/bin/startup.sh
瀏覽器輸入:http://127.0.0.1:9080/關閉TOMCAT/usr/local/tomcat1/bin/shutdown.sh/usr/local/tomcat1/bin/shutdown.sh/usr/local/tomcat1/bin/shutdown.sh nginx 下載:http://wiki.codemongers.com/NginxChspcre : http://sourceforge.net/projects/pcre/files/pcre/8
upstream
: http://code.google.com/p/nginx-upstream-jvm-route/downloads/detail?name=nginx-upstream-jvm-route-0.1.tar.gz&can=2&q=
(
1)、安裝pcre:
# tar zxvf pcre-8.30.tar.gz -C /usr/src/
# cd /usr/src/pcre-8.30/
# cd /usr/src/pcre-8.30/pcre-8.
configure
# make && make install (
2)、安裝外掛程式、
( # tar zxvf nginx-upstream-jvm-route-0.1.tar.gz -C /usr/src/
注意這裡是解壓縮到同一個資料夾,這裡的預設名字是nginx-1.0.13
# cd /usr/nginx-1.0.13/
# patch -p0
(
3)、安裝nginx:
# ./ configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre=/usr/src/pcre-8.30 --add-module=/usr/src/nginx_upstream_jvm_route --with-openssl=/usr / ( --user= --group=)# make && make install
(
4)、編輯nginx.conf:
# vi /usr/local/ nginx/conf/nginx.conf
user nobody;
worker_processes 8;
error_log logs/nginx_error.log crit; .pid;#Specifies the value for maximum file descriptors that can be opened by this process.worker_rlimit_nofile 20480;events{花 http { upstream aa { server 127.0.0.1:8080 max_fails=3 fail_timeout=50s; 7.0.0.1:8081 max_fails=3 fail_timeout=50s; } include mime.types; default_type application/octet-stream; #charset gb2312; size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_header_timeout 20 tcp_nopush 開; keepalive_timeout 60; tcp_nodelay 開; proxy_connect_timeoutp_nodelay 開; proxy_connect_timeout 300; ; proxy_send_timeout 20; proxy_buffer_size 96k; proxy_buffers 8 256k;_proxy_busyage_proxy_busyrite 2k; # proxy_store on;# proxy_store_access user:rw group:rw all:rw; proxy_temp_path /usr/local/nginx/proxy_temp;proxy_cache_path /usr/local/nginx/www level=1:2 keys_z inactive=1d max_size=2g;_gzip xion; length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2 css application/xml; gzip _vary on; # limit_zone 一個$binary_remote_addr 10m ; proxy_set_header 主機$host; proxy_set_header X-真實IP $remote_addr; proxy_set_header X 聽 80; server_name 192.168 .3.30; 索引index.html;# 重寫^/index.html / 最後;#rewrite ^/(.*)_p([0-9]*)_(. * )_e(.*)/(.*)_(.*)_t(.*)_o(.*)_(l|s|k|[0-9]*)$ /searchclassbigkey?skey=$1 &pno =$2&sw=$3&pe=$4&rk=$5&dekey=$6&tid=$7&ocs=$8&ocid=$9 最後;#rewrite ^/(.*)_p([0-9]*)_s(.* ) /(.*)_(.*)_(.*)$ /searchkey?skey=$1&pno=$2&sw=$3&pe=$4&rk=$5&dekey=$6 最後;# 重寫^/d-( 。 # proxy_headers_hash_max_size 1024;# proxy_headers_hash_bucket_size 128;# proxy_cache cache_one; proxy_cache_valid 200 304 2hxy proxy_cache_key $host$uri$is _args$args;# proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for ; proxy_pass http://aa; } { # proxy_cache cache_one; proxy_cache_valid 200 304 5h; xy_cache_key $host$uri$is_args$args; 過渡 8 小時; 8 小時; . // aa; } 位置 ~ .*.(js|cs cache_one; proxy_cache_valid 200 304 3h; proxy_cache_valid 任3m; proxy_cache_key $host$uri$is_args$args; ; proxy_pass http://aa; } log_format aa '$remote_addr - $remote_user [$ sent "$http_referer" ' '"$http_user_agent" $ http_x_forwarded_for'; access_log /usr/local/ nginx/logs/aa.log aa; } server_name 1 92.168.3.31; 索引索引.html; 位置 / { cache_valid 200 304 2h; proxy_cache_valid 任意 3m; proxy_cache_key $host$uri$is_args$args; proxy_pass http://bb;位置 ~ .*.(gif|jpg|jpeg| png |bmp| swf|js|css|html)$ { proxy_cache cache_one; proxy_cache_valid 任意3m; 過渡 8 小時; proxy_cache_key $host$uri$is_args$args; proxy_pass http://bb; ' $狀態$body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for';/log700 fin? } } # /usr/local/nginx/sbin/nginx -tnginx:設定檔/usr/local/nginx/conf/nginx.conf 語法沒問題nginx:設定檔/usr/local/nginx /conf/nginx .conf 測試成功 # /usr/local/nginx/sbin/nginx# netstat -anpt | grep 80 tcp 0 0:* 為
以上就介紹了centos下nginx+tomcat安裝配置nginx結合tomcat,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。