首页
JAVA笔记
数据库笔记
混乱记忆
小站记
您现在的位置
linux java + mysql + tomcat 环境安装
简介: 记录 java + mysql + tomcat 在 CentOS 5.9 x64 vps 部署环境的安装经过安装过程解决一些环境问题,特此记录

说明:这次环境是 CentOS 5.9 x64 的 VPS 环境所以安装过程会出现少 so 的情况,因为linux 本人也不熟悉,所以所有操作都是在 root 用户下进行。

 

首先下载到如下包并已经通过 SshClient 将文件传到 /tmp 目录

apache-tomcat-6.0.20.tar.gz

jdk-6u37-linux-x64.bin

MySQL-server-5.5.28-1.linux2.6.x86_64.rpm
MySQL-client-5.5.28-1.linux2.6.x86_64.rpm

 

安装 mysql

# rpm -ivh MySQL-server-5.5.28-1.linux2.6.x86_64.rpm
error: Failed dependencies:
        libaio.so.1()(64bit) is needed by MySQL-server-5.5.28-1.linux2.6.x86_64
        libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.5.28-1.linux2.6.x86_64
        libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.5.28-1.linux2.6.x86_64

  1. 解决办法:
    # wget http://mirror.centos.org/centos/5.9/os/x86_64/CentOS/libaio-0.3.106-5.x86_64.rpm
    下载完成后执行命令:
    # rpm -ivh libaio-0.3.106-5.x86_64.rpm
    warning: libaio-0.3.106-5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
    Preparing...                ########################################### [100%]
       1:libaio                 ########################################### [100%]
  2. 再次安装mysql
    #rpm -ivh MySQL-server-5.5.28-1.linux2.6.x86_64.rpm
    Preparing...                ########################################### [100%]
       1:MySQL-server           ########################################### [100%]
    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    To do so, start the server, then issue the following commands:
    /usr/bin/mysqladmin -u root password 'new-password'
    /usr/bin/mysqladmin -u root -h xiaoyunduo.org password 'new-password'
    Alternatively you can run:
    /usr/bin/mysql_secure_installation
    which will also give you the option of removing the test
    databases and anonymous user created by default.  This is
    strongly recommended for production servers.
    See the manual for more instructions.
    Please report any problems with the /usr/bin/mysqlbug script!
    安装后发现mysql server 没有启动,重启机器 mysql server 能够自动启动。
  3. 安装 mysql 客户端
    #rpm -ivh MySQL-client-5.5.28-1.linux2.6.x86_64.rpm
  4. 初始化
    #/usr/bin/mysql_secure_installation
    根据向导配置就可以了。
  5. 允许远程连接
    虽然在执行步骤4的时候运行远程连接了,但是我安装测试后还是连接不上,经过折腾得到解决办法如下(依次执行只要不出错就OK了):
    mysql -uUname -pMypass -h127.0.0.1
    use mysql
    create table xiaoyunduo as select * from user where Host='127.0.0.1';
    update xiaoyunduo set Host='%';
    insert into user (select * from xiaoyunduo);
    flush privileges;
  6. 连接测试
    本地: mysql -uUsername -pMypass -hlocalhost
    远程: mysql -uUsername -pMypass -h222.222.22.22
    测试都通过,但是远程连接不上,可能是防火墙主档了。

#rpm -ivh MySQL-server-5.5.28-1.linux2.6.x86_64.rpm
Preparing...                ########################################### [100%]
        file /usr/share/mysql/charsets/README from install of MySQL-server-5.5.28-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
        file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.5.28-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.73-3.el6_5.x86_64
  1. 解决办法:
    # yum list | grep mysql
  2. yum remove mysql-libs
  3. 最后再重新安装

安装 jdk

赋予执行权限:#chmod 755 jdk-6u37-linux-x64.bin
解压安装包:#./jdk-6u37-linux-x64.bin
将解压出的目录jdk1.6.0_37拷贝到需要的位置:#cp -r jdk1.6.0_37 /usr/local
修改/etc/profile 配置环境变量:
export JAVA_HOME=/usr/local/jdk1.6.0_37
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

重新加载:#source /etc/profile

安装 tomcat

解压安装包:#tar xvzf apache-tomcat-6.0.20.tar.gz  -C /usr/local

在startup.sh启动脚本中添加环境变量:
export JAVA_HOME=/usr/local/jdk1.6.0_37
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

配置tomcat自动启动:

在/etc/rc.local 文件中添加内容 /usr/local/apache-tomcat-6.0.20/bin/startup.sh

卸载 apache (目前用不到,后面可能会用 nginx)

#rpm -e httpd


删除默认的邮件系统

#rpm -e sendmail-doc
#rpm -e sendmail-cf
#rpm -e fetchmail
#rpm -e sendmail
#rpm -e cyrus-sasl                  //邮件认证服务  其守护进程名称是 saslauthd