首页 > 代码库 > centos下安装并配置tomcat
centos下安装并配置tomcat
1,安装jdk,centos默认安装了java-openjdk的环境,但是不带JDK,运行
yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel
2,下载apache-tomcat-7.0.56.tar.gz;
3.配置tomcat环境并设置为服务,采用jsvc
解压:tar vzvf apache-tomcat-7.0.56.tar.gz
重命名: mv apache-tomcat-7.0.56 /usr/local/apache-tomcat
cd /usr/local/apache-tomcat/bin
压缩:tar xvfz commons-daemon-native.tar.gz
cd commons-daemon-1.0.15-native-src/unix
./configure --with-java=/usr/lib/jvm/java/
make
cp jsvc ../..
cd ../..
拷贝/usr/local/apache-tomcat/bin目录下的daemon.sh到/etc/init.d,重命名为tomcat,用文本打开,第22行增加:
JAVA_HOME=/usr/lib/jvm/java
CATALINA_HOME=/usr/local/apache-tomcat
第94行TOMCAT_USER=tomcat改为TOMCAT_USER=root,保存
命令行中service tomcat start
firefox地址栏http://localhost:8080/
4.设置tomcat服务自启动
打开/etc/init.dtomcat,在第2行添加:
./etc/init.d/functions
保存,再依次执行
chmod 755 /etc/init.d/functions ← 将启动脚本属性设置为755(使之可执行)
chkconfig --add tomcat ← 将Tomcat加入到chkconfig中
chkconfig tomcat on ← 将Tomcat设置为自启动
chkconfig --list tomcat ← 确认Tomcat服务状态
tomcat 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← 确认2~5为on的状态就OK
转自 http://www.cnblogs.com/lovesumer/p/4079070.html
centos下安装并配置tomcat