JDK安装
cd /usr/local/src/
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-i586.tar.gz (下载JDK,因为oracle有接受的验证)
tar zxvf jdk-8u65-linux-i586.tar.gz (解压)
mv jdk1.8.0_65 /usr/local/jdk1.8.0_65 (移动文件夹到usr/local下)
vim /etc/profile.d/java.sh (编辑java.sh脚本,配置java环境变量)
JAVA_HOME=/usr/local/jdk1.8.0_65
JAVA_BIN=/usr/local/jdk1.8.0_65/bin
JRE_HOME=/usr/local/jdk1.8.0_65/jre
PATH=$PATH:/usr/local/jdk1.8.0_65/bin:/usr/local/jdk1.8.0_65/jre/bin
CLASSPATH=/usr/local/jdk1.8.0_65/jre/lib:/usr/local/jdk1.8.0_65/lib:/usr/local/jdk1.8.0_65/jre/lib/charsets.jar
. /etc/profile.d/java.sh (重新运行脚本)
java -version (查看java版本是否与当前版本一致)
yum remove java-1.6.0-openjdk* (卸载与当前版本不一致的包)
tomcat安装
cd /usr/local/src/
wget http://www.us.apache.org/dist/tomcat/tomcat-7/v7.0.65/bin/apache-tomcat-7.0.65.tar.gz
cd /usr/local/tomcat/bin (移动到tomcat的bin目录下)
cp -v catalina.sh /etc/init.d/tomcat (拷贝配置文件)
vim /etc/init.d/tomcat (编辑配置文件,如下)
# chkconfig: 2345 63 37
# description: tomcat server init script
# Source Function Library
. /etc/init.d/functions
JAVA_HOME=/usr/local/jdk1.8.0_65
CATALINA_HOME=/usr/local/tomcat
chkconfig --add tomcat (添加tomcat服务)
chkconfig tomcat on (设定tomcat在刚才编辑的配置文件运行级别下自动启动)
/etc/init.d/tomcat start (启动tomcat服务)
netstat -lnp (查看java中tomcat监听端口)
浏览器访问192.168.111.129:8080查看是否配置成功
tomcat配置
cd /usr/local/tomcat/conf
vim server.xml (编辑配置文件,添加或修改红色内容)
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Host name="www.111.com" appBase="/data/tomcatweb"
unpackWARs="false" autoDeploy="true" xmlValidation="false"
xmlNamespaceAware="false">
<Context path="" docBase="./" debug="0" reloadable="true" crossContext="true"/>
</Host>
mkdir /data/tomcatweb (创建appBase文件夹)
/etc/init.d/tomcat stop
/etc/init.d/tomcat start
netstat -lnp (查看监听端口是否修改)
vim /data/tomcatweb/1.txt
vim /data/tomcatweb/1.jsp (编辑一个jsp页面测试解析)
<html><body><center>
Now time is: <%=new java.util.Date()%>
</center></body></html>
curl -x192.168.111.129:80 www.111.com/1.txt (测试访问)
curl -x192.168.111.129:80 www.111.com/1.jsp (测试jsp解析)
resin安装与配置
cd /usr/local/src/
wget http://caucho.com/download/resin-4.0.46.tar.gz
tar zxvf resin-4.0.46.tar.gz
cd resin-4.0.46
./configure --prefix=/usr/local/resin --with-java-home=/usr/local/jdk1.8.0_65
make && make install
vim resin.properties (修改端口)
app.http : 80
vim resin.xml (添加虚拟目录,注意是在cluster id = "app"下添加)
<cluster id="app">
......
<host id="www.123.com" root-directory=".">
<web-app id="/" root-directory="/data/resinweb"/>
</host>
......
</cluster>
/etc/init.d/resin stop
/etc/init.d/resin start
netstat -lnp (查看监听端口)
curl -x127.0.0.1:80 www.123.com/1.jsp (测试解析)
本文转自 粗粮面包 51CTO博客,原文链接:http://blog.51cto.com/culiangmianbao/2052352,如需转载请自行联系原作者