nginx +tomcat
下载
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-6/v6.0.37/bin/apache-tomcat-6.0.37.tar.gz
wget http://download.oracle.com/otn-pub/java/jdk/7u21-b11/server-jre-7u21-linux-x64.tar.gz
解压
tar xvf apache-tomcat-6.0.37.tar.gz
tar xvf server-jre-7u21-linux-x64.tar.gz
mv apache-tomcat /usr/local/tomcat
mv jdk1.7.0_21/ /usr/java
配置环境变量
vi /etc/profile
JAVA_HOME="/usr/java"
CLASS_PATH="$JAVA_HOME/lib:$JAVA_HOME/jre/lib"
PATH="$JAVA_HOME/bin:.:$PATH"
CATALINA_HOME="/usr/local/tomcat"
export JAVA_HOME CATALINA_HOME
加载生效
source /etc/profile
查看java版本 java -version
启动tomcat
/usr/local/tomcat/bin/startup.sh
停止
/usr/local/tomcat/bin/shutdown.sh
测试
http://ip:8080 默认启动的是8080端口
安装nginx 这里就跳过了
配置jsp|jspx|do|wsdl 等用tomcat处理 php用192.168.1.23 的php处理
upstream tomcat_server {
server 127.0.0.1:8080;
}
#limit_zone crawler $binary_remote_addr 10m;
server {
listen 80;
server_name www.test.com;
index index.html index.htm index.jsp index.do default.jsp default.do index.php;
root /usr/www;
access_log /var/log/www/access11.log main;
if (-d $request_filename)
{
rewrite ^/(.*)([^/])$http://$host/$1$2/ permanent;
}
location ~ \.(jsp|jspx|do|wsdl)?$ {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://tomcat_server;
}
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 192.168.1.23:9000;
fastcgi_index index.php;
include fcgi.conf;
}
}
重启nginx 测试OK