安装配置jdk和tomcat

时间:2022-08-22 09:18:31

1,首先,暂停iptables服务

[root@localhost ~]# service iptables stop

[root@localhost ~]# chkconfig iptables off


2,jdk卸载

  (1)查找jdk安装信息

[root@iZ23s6vhhjjZ apache-tomcat-7.0.63]# rpm -qa|grep gcjlibgcj-4.4.7-4.el6.x86_64
java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
[root@iZ23s6vhhjjZ apache-tomcat-7.0.63]#rpm -e java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
[root@iZ23s6vhhjjZ apache-tomcat-7.0.63]#rpm -e libgcj-4.4.7-4.el6.x86_64

  (2)卸载

[root@iZ23s6vhhjjZ apache-tomcat-7.0.63]# rpm -qa|grep jdkjdk-1.7.0_79-fcs.x86_64[root@iZ23s6vhhjjZ apache-tomcat-7.0.63]#rpm -e  --nodeps jdk-1.7.0_79-fcs.x86_64

3,jdk的安装和配置:

  

  (1),安装jdk命令: rpm -ivh jdk-8u51-linux-x64.rpm

[root@localhost install]# lltotal 481168-rw-r--r--. 1 root root   8850470 Nov  2 22:43 apache-tomcat-7.0.63.tar.gz-rw-r--r--. 1 root root 137808216 Jan 13 15:09 jdk-8u51-linux-x64.rpm-rw-r--r--. 1 root root  33203321 Nov 20 11:31 mysql-5.6.25.tar.gz-rw-r--r--. 1 root root 312845162 Nov 13 15:19 mysql-5.6.27-linux-glibc2.5-x86_64.tar.gz[root@localhost install]# rpm -ivh jdk-8u51-linux-x64.rpm Preparing...                ########################################### [100%]   1:jdk1.8.0_51            ########################################### [100%]Unpacking JAR files...        rt.jar...        jsse.jar...        charsets.jar...        tools.jar...        localedata.jar...        jfxrt.jar...        plugin.jar...        javaws.jar...        deploy.jar...

   (2)配置环境变量:

[root@localhost install]# 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.pathmunge () {    case ":${PATH}:" in        *:"$1":*)            ;;        *)            if [ "$2" = "after" ] ; then                PATH=$PATH:$1            else                PATH=$1:$PATH            fi    esac}"/etc/profile" 78L, 1796C# By default, we want umask to get set. This sets it for login shell# Current threshold for system reserved uid/gids is 200# You could check uidgid reservation validity in# /usr/share/doc/setup-*/uidgid fileif [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then    umask 002else    umask 022fifor i in /etc/profile.d/*.sh ; do    if [ -r "$i" ]; then        if [ "${-#*i}" != "$-" ]; then            . "$i"        else            . "$i" >/dev/null 2>&1        fi    fidoneunset iunset -f pathmungeexport JAVA_HOME=/usr/java/jdk1.8.0_51export PATH=$JAVA_HOME/bin:$PATHexport CLASSPATH=$JAVA_HOME/lib:.:$CLASSPATH

 (3) 配置的环境变量生效:source /etc/profile

[root@localhost install]# source /etc/profile

(4)测试:

 查看java版本号:java -version

[root@localhost install]# java -versionjava version "1.8.0_51"Java(TM) SE Runtime Environment (build 1.8.0_51-b16)Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

查看javac版本号命令:javac -version 

[root@localhost install]# javac -versionjavac 1.8.0_51


4,tomcat安装配置

  (1),创建组和用户tomcat

[root@localhost install]# groupadd tomcat[root@localhost install]# useradd -g tomcat tomcat[root@localhost install]# passwd tomcatChanging password for user tomcat.New password: BAD PASSWORD: it is too simplistic/systematicBAD PASSWORD: is too simpleRetype new password: passwd: all authentication tokens updated successfully.[root@localhost install]#

  (2)切换用户并创建tomcat用户的目录:

[root@localhost install]# su tomcat[tomcat@localhost install]$ mkdir /home/tomcat/server [tomcat@localhost install]$

  (3)解压tomcat压缩包并放到指定的目录里

[tomcat@localhost install]$ tar zxvf apache-tomcat-7.0.63.tar.gz -C /home/tomcat/server/apache-tomcat-7.0.63/webapps/examples/jsp/xml/xml.jsp.htmlapache-tomcat-7.0.63/webapps/examples/servlets/chat/index.jspapache-tomcat-7.0.63/webapps/examples/servlets/chat/index.jsp.htmlapache-tomcat-7.0.63/webapps/examples/servlets/chat/login.jspapache-tomcat-7.0.63/webapps/examples/servlets/chat/login.jsp.htmlapache-tomcat-7.0.63/webapps/examples/servlets/chat/post.jspapache-tomcat-7.0.63/webapps/examples/servlets/chat/post.jsp.htmlapache-tomcat-7.0.63/webapps/examples/servlets/cookies.htmlapache-tomcat-7.0.63/webapps/examples/servlets/helloworld.htmlapache-tomcat-7.0.63/webapps/examples/servlets/images/code.gifapache-tomcat-7.0.63/webapps/examples/servlets/images/execute.gifapache-tomcat-7.0.63/webapps/examples/servlets/images/return.gifapache-tomcat-7.0.63/webapps/examples/servlets/index.htmlapache-tomcat-7.0.63/webapps/examples/servlets/reqheaders.htmlapache-tomcat-7.0.63/webapps/examples/servlets/reqinfo.htmlapache-tomcat-7.0.63/webapps/examples/servlets/reqparams.htmlapache-tomcat-7.0.63/webapps/examples/servlets/sessions.htmlapache-tomcat-7.0.63/webapps/examples/websocket-deprecated/chat.htmlapache-tomcat-7.0.63/webapps/examples/websocket-deprecated/echo.htmlapache-tomcat-7.0.63/webapps/examples/websocket-deprecated/index.htmlapache-tomcat-7.0.63/webapps/examples/websocket-deprecated/snake.htmlapache-tomcat-7.0.63/webapps/examples/websocket/chat.xhtmlapache-tomcat-7.0.63/webapps/examples/websocket/drawboard.xhtmlapache-tomcat-7.0.63/webapps/examples/websocket/echo.xhtmlapache-tomcat-7.0.63/webapps/examples/websocket/index.xhtmlapache-tomcat-7.0.63/webapps/examples/websocket/snake.xhtmlapache-tomcat-7.0.63/webapps/host-manager/META-INF/context.xmlapache-tomcat-7.0.63/webapps/host-manager/WEB-INF/jsp/401.jspapache-tomcat-7.0.63/webapps/host-manager/WEB-INF/jsp/403.jspapache-tomcat-7.0.63/webapps/host-manager/WEB-INF/jsp/404.jspapache-tomcat-7.0.63/webapps/host-manager/WEB-INF/web.xmlapache-tomcat-7.0.63/webapps/host-manager/images/add.gifapache-tomcat-7.0.63/webapps/host-manager/images/asf-logo.gifapache-tomcat-7.0.63/webapps/host-manager/images/code.gifapache-tomcat-7.0.63/webapps/host-manager/images/design.gifapache-tomcat-7.0.63/webapps/host-manager/images/docs.gifapache-tomcat-7.0.63/webapps/host-manager/images/fix.gifapache-tomcat-7.0.63/webapps/host-manager/images/tomcat.gifapache-tomcat-7.0.63/webapps/host-manager/images/update.gifapache-tomcat-7.0.63/webapps/host-manager/images/void.gifapache-tomcat-7.0.63/webapps/host-manager/index.jspapache-tomcat-7.0.63/webapps/host-manager/manager.xmlapache-tomcat-7.0.63/webapps/manager/META-INF/context.xmlapache-tomcat-7.0.63/webapps/manager/WEB-INF/jsp/401.jspapache-tomcat-7.0.63/webapps/manager/WEB-INF/jsp/403.jspapache-tomcat-7.0.63/webapps/manager/WEB-INF/jsp/404.jspapache-tomcat-7.0.63/webapps/manager/WEB-INF/jsp/sessionDetail.jspapache-tomcat-7.0.63/webapps/manager/WEB-INF/jsp/sessionsList.jspapache-tomcat-7.0.63/webapps/manager/WEB-INF/web.xmlapache-tomcat-7.0.63/webapps/manager/images/add.gifapache-tomcat-7.0.63/webapps/manager/images/asf-logo.gifapache-tomcat-7.0.63/webapps/manager/images/code.gifapache-tomcat-7.0.63/webapps/manager/images/design.gifapache-tomcat-7.0.63/webapps/manager/images/docs.gifapache-tomcat-7.0.63/webapps/manager/images/fix.gifapache-tomcat-7.0.63/webapps/manager/images/tomcat.gifapache-tomcat-7.0.63/webapps/manager/images/update.gifapache-tomcat-7.0.63/webapps/manager/images/void.gifapache-tomcat-7.0.63/webapps/manager/index.jspapache-tomcat-7.0.63/webapps/manager/status.xsdapache-tomcat-7.0.63/webapps/manager/xform.xsl

  (4)切换目录并配置文件:

[tomcat@localhost install]$ cd /home/tomcat/server/apache-tomcat-7.0.63/conf/[tomcat@localhost conf]$ cp server.xml server.xml.bak[tomcat@localhost conf]$ vi server.xml

 (5)启动关闭测试

[tomcat@localhost bin]$ /home/tomcat/server/tomcat/bin/startup.shUsing CATALINA_BASE:   /home/tomcat/server/apache-tomcat-7.0.63Using CATALINA_HOME:   /home/tomcat/server/apache-tomcat-7.0.63Using CATALINA_TMPDIR: /home/tomcat/server/apache-tomcat-7.0.63/tempUsing JRE_HOME:        /usrUsing CLASSPATH:       /home/tomcat/server/apache-tomcat-7.0.63/bin/bootstrap.jar:/home/tomcat/server/apache-tomcat-7.0.63/bin/tomcat-juli.jarTomcat started.[tomcat@localhost bin]$ ps -ef|grep tomcaroot      1535  1102  0 15:24 pts/0    00:00:00 su tomcattomcat    1536  1535  0 15:24 pts/0    00:00:00 bashtomcat    1568     1 30 15:31 pts/0    00:00:02 /usr/bin/java -Djava.util.logging.config.file=/home/tomcat/server/apache-tomcat-7.0.63/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/home/tomcat/server/apache-tomcat-7.0.63/endorsed -classpath /home/tomcat/server/apache-tomcat-7.0.63/bin/bootstrap.jar:/home/tomcat/server/apache-tomcat-7.0.63/bin/tomcat-juli.jar -Dcatalina.base=/home/tomcat/server/apache-tomcat-7.0.63 -Dcatalina.home=/home/tomcat/server/apache-tomcat-7.0.63 -Djava.io.tmpdir=/home/tomcat/server/apache-tomcat-7.0.63/temp org.apache.catalina.startup.Bootstrap starttomcat    1586  1536  4 15:31 pts/0    00:00:00 ps -eftomcat    1587  1536  0 15:31 pts/0    00:00:00 grep tomca[tomcat@localhost bin]$ netstat -lntp |grep 8080(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)tcp        0      0 :::8080                     :::*                        LISTEN      1568/java


本文出自 “清风明月” 博客,请务必保留此出处http://liqingbiao.blog.51cto.com/3044896/1734612