apache-tomcat7 在rhel7下的安装记录
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache-tomcat7 在rhel7下的安装记录相关的知识,希望对你有一定的参考价值。
tomcat7官方下载地址:http://tomcat.apache.org/download-70.cgi 最新版本:7.0.73
安装tomcat之前需安装jdk
下载地址:http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html #下载rpm包安装
安装jdk步骤:
[[email protected] ~]# rpm -ivh jdk-8u102-linux-x64.rpm
[[email protected] ~]# vi /etc/profile #添加环境变量
export JAVA_HOME=/usr/java/jdk1.8.0_102 #JDK默认的安装目录
export JAVA_BIN=/usr/java/jdk1.8.0_102/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
[[email protected] ~]# source /etc/profile
[[email protected] ~]# java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode) java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
安装tomcat步骤:
1、压到本地目录 如:/usr/local
2、添加环境变量
[[email protected] ~]# vi /etc/profile
export CATALINA_HOME=/usr/local/apache-tomcat-7.0.73
[email protected] ~]# source /etc/profile
3、启动tocmat
[[email protected] ~]# /usr/local/apache-tomcat-7.0.73/bin/satrtup.sh
Using CATALINA_BASE: /usr/local/apache-tomcat-7.0.73
Using CATALINA_HOME: /usr/local/apache-tomcat-7.0.73
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.73/temp
Using JRE_HOME: /usr/java/jdk1.8.0_102
Using CLASSPATH: /usr/local/apache-tomcat-7.0.73/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.70/bin/tomcat-juli.jar
4、配置管理员
[[email protected] ~]# vi /usr/local/apache-tomcat-7.0.70/conf/tomcat-users.xml
修改默认管理员
<tomcat-users>
<role rolename="admin-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="admin-script"/>
<role rolename="manager-status"/>
<role rolename="manager-gui"/>
<user username="admin" password="1234" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
</tomcat-users>
rhel7 开机自动启动(systemctl方式配置)
[[email protected] ~]# cd $CATALINA_HOME
[[email protected] apache-tomcat-7.0.73]# touch tomcat.pid
[[email protected]er bin]# vi setenv.sh
#set java runtime environment variable
export JAVA_HOME=/usr/java/jdk1.8.0_102
export JRE_HOME=/usr/java/jdk1.8.0_102/jre
# set APR
export LD_LIBRARY_PATH=/usr/local/apr/lib //需要安装APR
#add tomcat pid
CATALINA_PID="$CATALINA_HOME/tomcat.pid"
#add java opts
JAVA_OPTS="-server -Xms1024m -Xmx4096m -XX:PermSize=256M -XX:MaxNewSize=1024m -XX:MaxPermSize=512m -Djava.awt.headless=true"
[[email protected] bin]# vi /usr/lib/systemd/system/tomcat.service
[Unit]
Description=Tomcat
After=syslog.targetnetwork.target remote-fs.targetnss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/apache-tomcat-7.0.73/tomcat.pid
ExecStart=/usr/local/apache-tomcat-7.0.73/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID Private
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[[email protected] bin]# systemctl enable tomcat
[[email protected] bin]# systemctl start tomcat
[[email protected] systemd]# systemctl status tomcat
● tomcat.service - Tomcat
Loaded: loaded (/usr/lib/systemd/system/tomcat.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2016-12-08 15:43:44 CST; 1min ago
Process: 1251 ExecStart=/usr/local/apache-tomcat-7.0.73/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 2154 (java)
CGroup: /system.slice/tomcat.service
└─2154 /usr/java/jdk1.8.0_102/jre/bin/java -Djava.util.logging.config.file=/usr/local/apache-tomcat-7.0.73/conf/loggin...
Dec 08 15:43:42 app-server systemd[1]: Starting Tomcat...
Dec 08 15:43:44 app-server startup.sh[1251]: Using CATALINA_BASE: /usr/local/apache-tomcat-7.0.73
Dec 08 15:43:44 app-server startup.sh[1251]: Using CATALINA_HOME: /usr/local/apache-tomcat-7.0.73
Dec 08 15:43:44 app-server startup.sh[1251]: Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.73/temp
Dec 08 15:43:44 app-server startup.sh[1251]: Using JRE_HOME: /usr/java/jdk1.8.0_102/jre
Dec 08 15:43:44 app-server startup.sh[1251]: Using CLASSPATH: /usr/local/apache-tomcat-7.0.73/bin/bootstrap.jar:/usr/...li.jar
Dec 08 15:43:44 app-server startup.sh[1251]: Using CATALINA_PID: /usr/local/apache-tomcat-7.0.73/tomcat.pid
Dec 08 15:43:44 app-server startup.sh[1251]: Tomcat started.
Dec 08 15:43:44 app-server systemd[1]: Started Tomcat.
Hint: Some lines were ellipsized, use -l to show in full.
以上是关于apache-tomcat7 在rhel7下的安装记录的主要内容,如果未能解决你的问题,请参考以下文章