美文网首页
CentOS6.5下安装JDK1.7+MYSQL5.5+TOMC

CentOS6.5下安装JDK1.7+MYSQL5.5+TOMC

作者: alterem | 来源:发表于2019-11-08 11:25 被阅读0次

    ----------------CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档-----------------------


    【JDK1.7安装】


    1)登录Sun的JDK官方下载网 址:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

    2)下载jdk-7u67-linux-x64.rpm文件

    》删除系统自带OpenJDK

    CentOs6.5 默认会安装OpenOffice之类,需要JAVA支持,系统默认安装了一个openjdk1.7版本

    # java -version

    java version "1.7.0"

    OpenJDK Runtime Environment (build 1.7.0-b09)

    OpenJDK Client VM (build 1.7.0-b09, mixed mode)

    备注:

    无须删除原有的openjdk;否则,与之相关的openoffice等软件,也会自动随之删除;

    如果直接"应用程序-添加/删除软件--基本系统--java“删除其他相关软件也会自动删除,所以删除前,最好安装配置好新的JDK环境

    1. 删除原有的JDK:

    # rpm -qa|grep jdk

    查看安装的JDK,会显示多个java-1.7.0-openjdk-1.7.0相关的程序,在以下一一卸载。直到删完为止,如下:

    # rpm -e --nodeps java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el6_5.x86_64

    # rpm -e --nodeps java-1.7.0-openjdk-devel-1.7.0.65-2.5.1.2.el6_5.x86_64

    # rpm -e --nodeps java-1.7.0-openjdk-demo-1.7.0.65-2.5.1.2.el6_5.x86_64

    ......

    # rpm -qa|grep java

    查看安装的JAVA关联程序,在以下一一卸载。直到删完为止,如下:

    # rpm -e --nodeps tzdata-java-2014h-1.el6.noarch

    ......

    》配置新的JDK环境

    1)把安装文件文件保存在/usr/java/tools下 ,并切换到root用户

    # mkdir /usr/java 创建/urs/java目录

    # cd /usr/java/

    # rpm -ivh ./tools/jdk-7u67-linux-x64.rpm

    》配置jdk1.6.0_22环境变量

    # vi /etc/profile

    JAVA_HOME=/usr/java/jdk1.7.0_79

    JRE_HOME=/usr/java/jdk1.7.0_79/jre

    PATH=PATH:JAVA_HOME/bin:$JRE_HOME/bin

    CLASSPATH=:JAVA_HOME/lib/dt.jar:JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

    export JAVA_HOME JRE_HOME PATH CLASSPATH

    》使环境变量生效:

    #source /etc/profile

    》测试安装

    1)查看版本号

    # java -version

    java version "1.7.0_67"

    Java(TM) SE Runtime Environment (build 1.7.0_67-b01)

    Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

    Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)

    说明成功了。


    【MYSQL5.5的安装】


    安装方式分为rpm和源码编译安装两种,本文是采用mysql源码编译方式,编译器使用Cmake。软件需要mysql-5.5.40.tar.gz和cmake-2.8.10.2.tar.gz,请自行下载。

    》下载地址:

    http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.40.tar.gz

    http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz

    其中mysql使用最新的稳定版本,即最新试用版的上一个版本,且非rc或者alpha的版本,Cmake直接用的最新版。

    》上传mysql-5.5.40.tar.gz和cmake-2.8.10.2.tar.gz到/usr/java/tools文件夹下。

    》CentOS安装g++和ncurses-devel

    # yum install gcc-c++

    # yum install ncurses-devel

    》cmake的安装

    # mkdir -p /usr/java/make

    # cd /usr/java/make

    # mv ../tools/cmake-2.8.10.2.tar.gz ./

    # tar -zxv -f cmake-2.8.10.2.tar.gz

    # cd cmake-2.8.10.2

    # ./configure

    # make

    # make install

    》将cmake永久加入系统环境变量

    》用vi在文件/etc/profile文件中增加变量,使其永久有效,

    # vi /etc/profile

    》在文件PATH中加入MAKE_PATH环境变量:

    JAVA_HOME=/usr/java/jdk1.7.0_67

    JRE_HOME=/usr/java/jdk1.7.0_67/jre

    MAKE_PATH=/usr/java/cmake/cmake-2.8.10.2/bin

    PATH=MAKE_PATH:PATH:JAVA_HOME/bin:JRE_HOME/bin

    CLASSPATH=:JAVA_HOME/lib/dt.jar:JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

    export JAVA_HOME JRE_HOME PATH CLASSPATH

    》执行以下代码使刚才的修改生效:

    # source /etc/profile

    》用 export 命令查看PATH值

    # echo $PATH

    》创建mysql的安装目录及数据库存放目录

    # mkdir -p /usr/java/mysql //安装mysql

    # mkdir -p /usr/java/mysql/data //存放数据库

    》创建mysql用户及用户组

    # groupadd mysql

    # useradd -r -g mysql mysql

    》编译安装mysql

    # cd /usr/java/mysql

    # tar zxvf ../tools/mysql-5.5.40.tar.gz

    # cd mysql-5.5.40/

    # cmake -DCMAKE_INSTALL_PREFIX=/usr/java/mysql \

    -DMYSQL_UNIX_ADDR=/usr/java/mysql/mysql.sock \

    -DDEFAULT_CHARSET=utf8 \

    -DDEFAULT_COLLATION=utf8_general_ci \

    -DWITH_MYISAM_STORAGE_ENGINE=1 \

    -DWITH_INNOBASE_STORAGE_ENGINE=1 \

    -DWITH_MEMORY_STORAGE_ENGINE=1 \

    -DWITH_READLINE=1 \

    -DENABLED_LOCAL_INFILE=1 \

    -DMYSQL_DATADIR=/usr/java/mysql/data \

    -DMYSQL_USER=mysql \

    -DMYSQL_TCP_PORT=6666

    # make

    # make install

    》检验是否安装成功

    # cd /usr/java/mysql

    [root@fiona mysql]# ls

    bin data include lib mysql-5.5.40 mysql-test scripts sql-bench

    COPYING docs INSTALL-BINARY man mysql.sock README share support-files

    有bin等以上文件的话,恭喜你已经成功安装了mysql。

    》配置mysql

    》设置mysql目录权限

    # cd /usr/java/mysql //把当前目录中所有文件的所有者设为root,所属组为mysql

    # chown -R root:mysql .

    # chown -R mysql:mysql data

    》将mysql的启动服务添加到系统服务中

    # cp support-files/my-medium.cnf /etc/my.cnf

    cp:是否覆盖"/etc/my.cnf"? y

    》创建系统数据库的表

    # cd /usr/java/mysql

    # scripts/mysql_install_db --user=mysql

    》设置环境变量

    # vi /root/.bash_profile

    在修改PATH=PATH:HOME/bin为:

    PATH=PATH:HOME/bin:/usr/java/mysql/bin:/usr/java/mysql/lib

    # source /root/.bash_profile //使刚才的修改生效

    》手动启动mysql

    # ./bin/mysqld_safe --user=mysql & //启动MySQL,但不能停止

    mysqladmin -u root -p shutdown //此时root还没密码,所以为空值,提示输入密码时,直接回车即可。

    》将mysql的启动服务添加到系统服务中

    # cp support-files/mysql.server /etc/init.d/mysql

    》启动mysql

    # service mysql start

    Starting MySQL... ERROR! The server quit without updating PID file (/usr/java/mysql/data/localhost.localdomain.pid).

    》启动失败:

    》我这里是权限问题,先改变权限

    # chown -R mysql:mysql /usr/java/mysql

    》接着启动服务器

    # /etc/init.d/mysql start

    》修改MySQL的root用户的密码以及打开远程连接

    # mysql -u root mysql

    mysql> use mysql;

    mysql> desc user;

    mysql> GRANT ALL PRIVILEGES ON . TO root@"%" IDENTIFIED BY "root"; //为root添加远程连接的能力

    mysql> update user set Password = password('x123456.') where User='root'; //设置root用户密码

    mysql> select Host,User,Password from user where User='root';

    mysql> flush privileges;

    mysql> exit

    》重新登录

    # mysql -u root -p

    enter password:x123456.000

    》若还不能进行远程连接,关闭防火墙

    [root@localhost]# /etc/rc.d/init.d/iptables stop

    用远程工具连接上了表示成功了。


    【TOMCAT7.0的安装】


    》先下载apache-tomcat-7.0.56.tar.gz

    》下载地下:http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.56/bin/apache-tomcat-7.0.56.tar.gz

    # cd /usr/java

    # tar -zxvf ./tools/apache-tomcat-7.0.56.tar.gz

    # cd /etc/rc.d/init.d

    # vi tomcat

    #----------输入以下信息---------------------

    #

    # chkconfig: 345 80 15

    # description: Tomcat is a Servlet+JSP Engine.

    # Enter the jdk installation directory

    jdk_File=/usr/java/jdk1.7.0_67

    # Enter the tomcat installation directory

    tomcat_File=/usr/java/apache-tomcat-7.0.56

    export JAVA_HOME=$jdk_File

    # Source function library.

    . /etc/rc.d/init.d/functions

    start(){

    if [ -z $(/sbin/pidof java) ]; then

    echo "Starting tomcat"

    $tomcat_File/bin/startup.sh

    touch /var/lock/subsys/tomcat

    else

    echo "tomcat allready running"

    fi

    }

    stop(){

    if [ ! -z $(/sbin/pidof java) ]; then

    echo "Shutting down tomcat"

    $tomcat_File/bin/shutdown.sh

    until [ -z $(/sbin/pidof java) ]; do :; done

    rm -f /var/lock/subsys/tomcat

    else

    echo "tomcat not running"

    fi

    }

    case "$1" in

    start)

    start

    ;;

    stop)

    stop

    ;;

    restart)

    stop

    start

    ;;

    status)

    $tomcat_File/bin/catalina.sh version

    ;;

    *)

    echo "Usage: $0 {start|stop|restart|status}"

    esac

    exit 0

    #----------输入以下信息---------------------

    :wq! #保存退出

    # chmod 755 /etc/rc.d/init.d/tomcat #添加执行权限

    # chkconfig --add tomcat #添加服务

    # chkconfig tomcat on #设置开机启动

    # service tomcat stop #停止

    # service tomcat start #启动

    # service tomcat restart #重启

    # service tomcat status #查看状态信息

    ————————————————————————————————————————————————————————————————————————————————————————————

    【nginx-1.7.6.tar.gz的安装】


    》先下载nginx-1.7.6.tar.gz

    》下载URL:http://nginx.org/download/nginx-1.7.6.tar.gz

    》把nginx-1.7.6.tar.gz放到/usr/java/tools目录下

    # cd /usr/local/

    # tar -zxvf /usr/java/tools/nginx-1.7.5.tar.gz

    # cd nginx-1.7.6/

    # yum -y install pcre-devel

    # yum install -y zlib-devel

    # ./configure

    # make && make install

    # cd /usr/local/nginx

    # cd sbin

    # ./nginx

    # /etc/rc.d/init.d/iptables stop

    》配置服务器启动方式

    # vi /etc/init.d/nginx

    #---------输入以下信息------------------

    # nginx Startup script for the Nginx HTTP Server

    # it is v.0.0.2 version.

    # chkconfig: - 85 15

    # description: Nginx is a high-performance web and proxy server.

    # It has a lot of features, but it's not for everyone.

    # processname: nginx

    # pidfile: /software/nginx/logs/nginx.pid

    # config: /software/nginx/conf/nginx.conf

    nginxd=/usr/local/nginx/sbin/nginx

    nginx_config=/usr/local/nginx/conf/nginx.conf

    nginx_pid=/usr/local/nginx/logs/nginx.pid

    RETVAL=0

    prog="nginx"

    # Source function library.

    . /etc/rc.d/init.d/functions

    # Source networking configuration.

    . /etc/sysconfig/network

    # Check that networking is up.

    [ ${NETWORKING} = "no" ] && exit 0

    [ -x $nginxd ] || exit 0

    # Start nginx daemons functions.

    start() {

    if [ -e $nginx_pid ];then

    echo "nginx already running...."

    exit 1

    fi

    echo -n "Startingprog: "

    daemon nginxd -c{nginx_config}

    RETVAL=$?

    echo

    [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx

    return $RETVAL

    }

    # Stop nginx daemons functions.

    stop() {

    echo -n "Stoppingprog: "

    killproc $nginxd

    RETVAL=$?

    echo

    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid

    }

    reload() {

    echo -n "Reloadingprog: "

    #kill -HUP cat ${nginx_pid}

    killproc $nginxd -HUP

    RETVAL=$?

    echo

    }

    # See how we were called.

    case "$1" in

    start)

    start

    ;;

    stop)

    stop

    ;;

    reload)

    reload

    ;;

    restart)

    stop

    start

    ;;

    status)

    status $prog

    RETVAL=$?

    ;;

    *)

    echo "Usage:prog {start|stop|restart|reload|status|help}"

    exit 1

    esac

    exit $RETVAL

    #---------输入以下信息------------------

    # chmod 755 /etc/init.d/nginx && chkconfig nginx on

    # service nginx start

    # service nginx stop

    # service nginx restart

    # ps -ef | grep nginx

    # netstat -pant | grep 80

    》测试在浏览器中输入广域网IP看看能不能看到欢迎界面,如果能就表示成功了。

    ————————————————————————————————————————————————————————————————————————————————————————————

    【配置规则】


    # vi /etc/sysconfig/iptables

    增加如下配置:

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 8888 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 6666 -j ACCEPT

    # service iptables restart

    》系统启动的方式为自启动

    # chkconfig mysql on

    # chkconfig nginx on

    # chkconfig tomcat on

    ----------------------------------------------------------------------------------------------------

    所有环境安装完成。欢迎使用CentOS6.5,祝大家一用便会。

    ----------------------------------------------------------------------------------------------------

    相关文章

      网友评论

          本文标题:CentOS6.5下安装JDK1.7+MYSQL5.5+TOMC

          本文链接:https://www.haomeiwen.com/subject/jfuibctx.html