这是我的页面头部

centos 7 中 tomcat 安装

 

一、 安装 jdk

 

[root@iZm5ei4m ~]# /usr/local/tomcat/bin/startup.sh

一、安装 jdk

二、设置环境变量

########################################
#jdk环境变量配置
#########################################
export JAVA_HOME=/usr/java/jdk1.8.0_111/
export JRE_HOME=${JAVA_HOME}jre
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin

三、测试是否正常运行

[root@iZm5ei4m bin]# netstat -an|grep 8080
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
[root@iZm5ei4m bin]# wget 127.0.0.1:8080
--2016-11-15 13:41:20--  http://127.0.0.1:8080/
Connecting to 127.0.0.1:8080... connected.
HTTP request sent, awaiting response... 200
Length: unspecified [text/html]
Saving to: ‘index.html’

    [ <=>                                                                                                                               ] 11,236      --.-K/s   in 0s

2016-11-15 13:41:20 (22.5 MB/s) - ‘index.html’ saved [11236]

[root@iZm5ei4m bin]#

 

四、配置作为服务支行时使用的环境变量

[root@iZm5ei4mxt5qb65ldoxpywZ bin]# vi /usr/local/tomcat/bin/setenv.sh

export CATALINA_HOME=/usr/local/tomcat
export CATALINA_BASE=/usr/local/tomcat
#set java runtime environment variable
export JAVA_HOME=/usr/java/jdk1.8.0_111
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
#set apr
export LD_LIBRARY_PATH=/usr/local/apr/lib
#add tomcat pid
CATALINA_PID=${CATALINA_BASE}/tomcat.pid
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"

五、添加服务:

 

 

[Unit]
Description=Tomcat
After=syslog.targetnetwork.target remote-fs.targetnss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/tomcat/tomcat.pid
#MAINPID=/usr/local/tomcat/tomcat.pid
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
#ExecStop=/bin/kill -s QUIT $MAINPID
ExecStop=/usr/local/tomcat/bin/shutdown.sh
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

 

六、启用服务:

[root@iZm5ei4m bin]# systemctl enable tomcat
Created symlink from /etc/systemd/system/multi-user.target.wants/tomcat.service to /usr/lib/systemd/system/tomcat.service.

 

posted @ 2016-11-15 13:42  范晨鹏  阅读(444)  评论(0编辑  收藏  举报