一。系统环境:
Linux version 3.10.42-52.145.amzn1.x86_64
卸载OpenJDK
#java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
#rpm -qa |grep java
java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64
tzdata-java-2012c-1.el6.noarch
#rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64
#rpm -qa |grep java
tzdata-java-2012c-1.el6.noarch
#rpm -e --nodeps tzdata-java-2012c-1.el6.noarch
#rpm -qa |grep java
#java -version
bash: /usr/bin/java: 没有那个文件或目录
二。软件、文件准备:
tomcat服务器:apache-tomcat-6.0.41.zip
日志库:log4j-1.2.17.jar
Amazon API认证文件:credentials
JDK安装包:jdk-7u67-linux-x64.rpm
工程文件:
TestDemo.war
三、环境安装:安装JDK,安装Tomcat并配置
1.下载JDK7
#wget --no-cookies --no-check-certificate --header "Cookie:
gpw_e24=http%3A%2F%2Fwww.oracle.com%2F;
oraclelicense=accept-securebackup-cookie"
"http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-x64.rpm"
2.安装JDK7
#rpm -ivh jdk-7u67-linux-x64.rpm
说明:JDK默认会安装到/usr/java/目录下
3.配置JAVA_HOME,CLASSPATH,PATH环境变量
#vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_67
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib
#source /etc/profile
4.下载Tomcat6,
#wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-6/v6.0.41/bin/apache-tomcat-6.0.41.zip
5.解压Tomcat6,并在[tomcat]/bin/cataline.sh文件开始加入:JAVA_OPTS='-Xms512m -Xmx512m'
将[tomcat]/webapps目录下与项目不相关的文件和文件夹删除,为了安全
将log4j-1.2.17.jar文件拷贝到[tomcat]/lib目录下
注意:这里解压完Tomcat通常要启动一下Tomcat,测试一下能否通过外网访问,如果不能需要给Instance添加安全策略
6.设置Tomcat开机启动
修改[tomcat]/bin目录下文件权限为可执行
#chmod 755 *
在/etc/rc.d/rc.local中加入:
#vi /usr/local/tomcat/bin/
如:/usr/local/tomcat/bin/startup.sh
7.启动Tomcat并测试
服务启动过后访问:http://ec2-ip.us-west-2.compute.amazonaws.com:8080/TestDemo