1、安装jdk
cd /tmp tar -zxvf jdk-7u79-linux-x64.tar.gz -C /usr/local cd /usr/local/ ln -sv jdk1.7.0_79 java vim /etc/profile.d/java.sh #编辑该文件,添加下面内容 -------------------------- #!/bin/bash # export JAVA_HOME=/usr/local/java export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH -------------------------- source /etc/profile #执行该命令 java -version #查看java是否安装成功
2、安装tomcat
cd /tmp tar -zxvf apache-tomcat-7.0.70.tar.gz -C /usr/local/ cd /usr/local/ ln -sv apache-tomcat-7.0.70 tomcat vim /etc/profile.d/tomcat.sh #编辑该文件,添加下面内容 ------------ export CATALINA_HOME=/usr/local/tomcat export PATH=$CATALINA_HOME/bin:$PATH ------------ source /etc/profile #执行该文件 catalina.sh version #查看tomcat是否安装成功
3、tomcat.service 自启动
#vim /lib/systemd/system/tomcat.service 或 vim /usr/lib/systemd/system/tomcat.service [Unit] Description=Tomcat After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking Environment='JAVA_HOME=/usr/local/java' Environment='CATALINA_PID=/usr/local/apache-tomcat-7.0.70/bin/tomcat.pid' Environment='CATALINA_HOME=/usr/local/apache-tomcat-7.0.70/' Environment='CATALINA_BASE=/usr/local/apache-tomcat-7.0.70/' Environment='CATALINA_OPTS=-Xms1024M -Xmx1024M -server -XX:+UseParallelGC' WorkingDirectory=/usr/local/apache-tomcat-7.0.70/ ExecStart=/usr/local/apache-tomcat-7.0.70/bin/startup.sh ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
4、设置自启动
systemctl enable tomcat.service
systemctl start tomcat.service
systemctl status tomcat.service
查看服务状态
ps -ef | grep tomcat
netstat -antp
原文地址:http://blog.51cto.com/shunzi115/2063275
时间: 2024-10-28 21:41:09