在 Linux RedHatEL6 环境下安装配置 JDK1.7 + Tomcat7.0 + MySQL5.6

时间:2022-11-14 04:10:14

RedHatEL6

JDK安装路径: /usr/java/jdk1.7
Tomcat安装路径:/usr/local/tomcat7/
MySQL安装路径: /usr/local/mysql

总共分为以下几个步骤: 
1、安装配置jdk1.7 
2、安装配置Tomcat7.0和测试
3、安装MySQL和测试

所需要的软件:                                              
jdk-7u25-linux-x64.rpm                    
apache-tomcat-7.0.41.tar.gz               
MySQL-server-5.6.12-1.el6.x86_64.rpm      
MySQL-client-5.6.12-1.el6.x86_64.rpm

下载地址

http://download.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-x64.rpm
http://mirror.cc.columbia.edu/pub/software/apache/tomcat/tomcat-7/v7.0.41/bin/apache-tomcat-7.0.41.tar.gz
http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-server-5.6.12-1.el6.x86_64.rpm/from/http://cdn.mysql.com/
http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-client-5.6.12-1.el6.x86_64.rpm/from/http://cdn.mysql.com/

1,安装配置JDK
chmod u+x jdk-7u25-linux-x64.rpm         //安装包权限设置为可执行
rpm –ivh jdk-7u25-linux-x64.rpm            //执行安装,路径自动为 /usr/java/ jdk1.7.0_25
cd /usr/java                                            //进入安装好的目录
ln –s jdk1.7.0_25 jdk1.7                        //做个软连接到jdk1.7.0_25

设置环境变量:
Vim 打开 /etc/profile并将以下语句写入:
export JAVA_HOME="/usr/java/jdk1.7"
export PATH="$PATH:$JAVA_HOME/bin"
export CLASSPATH="$JAVA_HOME/lib"
export CATALINA_HOME="/usr/local/tomcat7.0"
保存退出,为让新配置生效,运行#source /etc/profile

2,配置Tomcat  
cd /usr/local
tar -xzvf /usr/downloads/apache-tomcat-7.0.41.tar.gz        //解压
ln -s apache-tomcat-7.0.41 tomcat7.0                                //做个软连接到apache-tomcat-7.0.41

测试Tomcat
启动Tomcat:
cd /usr/local/tomcat7.0/bin
startup.sh
关闭Tomcat:
cd /usr/local/tomcat7.0/bin
shutdown.sh
 
若看到以下信息说明配置正常: 
Using CATALINA_BASE: /usr/local/tomcat7.0
Using CATALINA_HOME: /usr/local/tomcat7.0
Using CATALINA_TMPDIR: /usr/local/tomcat7.0/temp 
Using JAVA_HOME: /usr/java/jdk1.7

打开浏览器,输入http://主机IP:8080,如果能看到tom,那就说明tomcat配置成功

3,安装MySQL
先检查系统是否已经安装MySQL,如果有就将其卸载
检查:rpm –qa|grep mysql
卸载:rpm –e –nodeps mysql*

安装MySQL Server
rpm –ivh MySQL-server-5.6.12-1.el6.x86_64.rpm
安装MySQL Client
rpm –ivh MySQL-client-5.6.12-1.el6.x86_64.rpm

测试MySQL
找到初始密码(安装完server会有提示密码文件所在位置):vim /root/.mysql_secret
首次登陆:mysql –u root –p
输入初始密码即可成功登陆
更改初始密码:mysql>set password=password(‘你想设置的密码’);