Linux运维学习小站

Linux maintenance study site

配置Tomcat

1、安装jdk

wget http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.tar.gz    //下载jdk
tar zxvf jdk-8u65-linux-x64.tar.gz      //解压
mv jdk1.8.0_65/ /usr/local/
vim /etc/profile
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
export  JAVA_HOME JAVA_BIN JRE_HOME PATH CLASSPATH
source /etc/profile
java -version

2、安装Tomcat

wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.28/bin/apache-tomcat-8.0.28.tar.gz      //下载tomcat
tar zxvf apache-tomcat-8.0.28.tar.gz
mv apache-tomcat-8.0.28 /usr/local/tomcat
cp -p /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
vim /etc/init.d/tomcat
#chkconfig: 112 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
chmod 755 /etc/init.d/tomcat
chkconfig --add tomcat
chkconfig tomcat on
service tomcat start      //启动tomcat
ps aux |grep tomcat       //查看是否启动成功
http://192.168.0.133:8080/      //浏览器输入此地址会打开Tomcat主界面

3、配置Tomcat

Tomcat默认的端口为8080,如果要修改默认端口则需修改文件:/usr/local/tomcat/conf/server.xml,保存文件后重启Tomcat:service tomcat stop,service tomcat start(#此脚本不支持restart)

4、配置新的虚拟主机

cd /usr/local/tomcat/conf/
vim server.xml
<Host name="localhost"  appBase="/data/tomcatweb"
        unpackWARs="false" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">
        <Context path="" docBase="./" debug="0" reloadable="true" crossContext="true"/>
    </Host>
service tomcat stop
service tomcat start


发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

© Linux运维学习小站 | 京ICP备15009755号-2 |
Powered by Z-BlogPHP & Yiwuku.com