Linux系统JDK+Tomcat环境安装布署过程
Linux系统JDK+Tomcat环境安装布署
正好这两天生产环境需要配置JAVA环境,因此将整个安装布署过程记录下来,仅供大家做个参考,需要的小伙伴们可以看看
1、系统环境
[root@centos6 ~]# cat /etc/redhat-release CentOS release 6.5 (Final) [root@centos6 ~]# uname -r 2.6.32-431.el6.x86_64 Apache版本信息如下 [root@centos6 tomcat]# /application/apache/bin/apachectl -v Server version: Apache/2.4.23 (Unix) Server built: Nov 22 2016 13:15:17
2、准备需要安装的软件
apache-tomcat-8.0.39.tar.gz jdk1.7.0_25.tar.gz 安装apache服务请参考前面的章节
3、配置JKD
[root@centos6 tools]# tar zxf jdk1.7.0_25.tar.gz [root@centos6 tools]# mv jdk1.7.0_25 /application/jdk [root@centos6 tools]# ll /application/jdk total 19724 drwxr-xr-x.210011001 4096 Jun 12 2015 bin -r--r--r--. 1 1001 1001 3339 Jun 12 2015 COPYRIGHT drwxr-xr-x. 4 1001 1001 4096 Jun 12 2015 db drwxr-xr-x. 3 1001 1001 4096 Jun 12 2015 include drwxr-xr-x. 5 1001 1001 4096 Jun 12 2015 jre drwxr-xr-x. 3 1001 10014096 Jun 12 2015 lib -r--r--r--. 1 1001 1001 40 Jun 12 2015 LICENSE drwxr-xr-x. 5 10011001 4096 Jun 12 2015 man -r--r--r--. 1 1001 1001 14 Jun 12 2015 README.html -rw-r--r--. 1 1001 1001444 Jun 12 2015 release -rw-r--r--. 1 1001 1001 19852231 Jun 12 2015 src.zip -rw-r--r--. 1 1001 1001123324 Jun 12 2015 THIRDPARTYLICENSEREADME-JAVAFX.txt -r--r--r--. 1 1001 1001 172252 Jun 12 2015 THIRDPARTYLICENSEREADME.txt 配置JDK需要的环境变量 [root@centos6 tools]# vi /etc/profile /etc/profile System wide environment and startup programs, for login setup Functions and aliases go in /etc/bashrc It's NOT a good idea to change this file unless you know what you are doing. It's much better to create a custom.sh shell script in /etc/profile.d/ to make custom changes to your environment, as this will prevent the need for merging in future updates. 在最后增加如下配置 JAVA_HOME=/application/jdk export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar [root@centos6 tools]# source /etc/profile 测试是否安装成功 [root@centos6 tools]# java -version java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode) 如果出现上述信息表明安装成功
4、安装配置tomcat
[root@centos6 tools]# tar zxf apache-tomcat-8.0.39.tar.gz [root@centos6 tools]# mv apache-tomcat-8.0.39 /application/tomcat [root@centos6 tools]# cd /application/tomcat/ [root@centos6 tomcat]# cd bin/ [root@centos6 bin]# tar zxf commons-daemon-native.tar.gz [root@centos6 bin]# cd commons-daemon-1.0.15-native-src/unix/ [root@centos6 unix]# ./configure --with-java=/application/jdk *** Writing output files *** configure: creating ./config.status config.status: creating Makefile config.status: creating Makedefs config.status: creating native/Makefile *** All done *** Now you can issue "make" [root@centos6 unix]# make 完成后会生成一个文件jsvc [root@centos6 unix]# ll jsvc -rwxr-xr-x. 1 root root 143689 Nov 27 20:49 jsvc 将jsvc文件拷贝至/tomcat/bin目录下 [root@centos6 unix]# cp jsvc /application/tomcat/bin/ [root@centos6 unix]# ll /application/tomcat/bin/jsvc -rwxr-xr-x. 1 root root 143689 Nov 27 20:50 /application/tomcat/bin/jsvc 配置daemon.sh test".$TOMCAT_USER" = . && TOMCAT_USER=tomcat Set JAVA_HOME toworking JDK or JRE #JAVA_HOME=/opt/jdk-1.6.0.22 If not set we'lltry to guess the JAVA_HOME #from java binaryif on the PATH
<-------修改如下----> test".$TOMCAT_USER" = . && TOMCAT_USER=tomcat Set JAVA_HOME toworking JDK or JRE JAVA_HOME=/application/jdk If not set we'lltry to guess the JAVA_HOME from java binaryif on the PATH
配置用户与权限 [root@centos6 unix]# useradd tomcat -M -s /sbin/nologin [root@centos6 unix]# chown -R tomcat /application/tomcat [root@centos6 unix]# chmod +x /application/tomcat/bin/*.sh
5、测试服务
启动服务 [root@centos6 unix]# /application/tomcat/bin/daemon.sh start
配置规范启动
[root@centos6 unix]# ln -s /application/tomcat/bin/daemon.sh /etc/init.d/tomcat
[root@centos6 unix]# chmod +x /etc/init.d/tomcat
[root@centos6 unix]# /etc/init.d/tomcat stop
[root@centos6 unix]# /etc/init.d/tomcat start
[root@centos6 unix]# /etc/init.d/tomcat stop
[root@centos6 unix]# ps -ef|grep tomcat|grep -v grep|wc -l
0[root@centos6 unix]# /etc/init.d/tomcat start
[root@centos6 unix]# ps -ef|grep tomcat|grep -v grep|wc -l
2
说明配置是正确的,启动成功
长按关注公众号——友侃有笑