Linux下java环境的搭建

一、安装jdk 我的版本是:jdk-6u10-linux-i586.rpm

安装jdk1.6安装包: rpm -ivh jdk-6u10-linux-i586.rpm
配置环境变量:
1,进入profile文件:vi/etc/profile
2,在文件中添加以下代码:
export JAVA_HOME = /usr/usr/java/jdk1.6.0_10 --jdk安装目录
export CALSSPATH = $JAVA_HOME/lib/*.* --jar包所在目录
export PATH = $PATH:$JAVA_HOME/bin --bin目录
重启系统:reboot
测试安装结果:
输入java回车:出现下面情况:

java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)

where options include:
-d32 use a 32-bit data model if available
(此处省略一些内容)
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
输入javac出现下面情况:
javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
(此处省略一些内容)
-help Print a synopsis of standard options
-Akey[=value] Options to pass to annotation processors
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system
说明安装成功!

二、安装tomcat
版本是:apache-tomcat-6.0.18.tar.gz
将安装包拷贝到/user/local下即可
然后直接解压:tar -zxvf - apache-tomcat-6.0.18.tar.gz
解压完后会有一个与安装包同名的目录
启动tomcat :进入到bin目录里:cd /usr/local/apache-tomcat-6.0.18/bin
输入:./startup.sh
出现:
Using CATALINA_BASE: /usr/local/apache-tomcat-6.0.18
Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.18
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.18/temp
Using JRE_HOME: /usr
启动成功!
代开IE输入:http://192.168.200.239:8080即可登录tomcat欢迎页面
我的虚拟机里的linux系统ip是:http://192.168.200.239,
可通过ifconfig查看系统ip
同样在/usr/local/apache-tomcat-6.0.18/bin 目录下
通过./shutdown.sh 关闭tomcat

三、安装mysql
安装包:MySQL-client-community-5.0.67-0.rhel4.i386.rpm
MySQL-server-community-5.0.67-0.rhel4.i386.rpm

安装mysql数据库服务器:rpm -ivh --nodeps MySQL-server-community-5.0.67-0.rhel4.i386.rpm
安装过程出现以下内容:
warning: MySQL-server-community-5.0.67-0.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-server-community ########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! ---注:让你为用户root设置一个密码
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 localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation
(此处省略一部分内容,主要是介绍mysql的)

Starting MySQL.[ OK ] (注释:mysql启动了)
Giving mysqld 2 seconds to start
# mysql -uroot -proot
-bash: /usr/bin/mysql: No such file or directory

安装mysql客户端: rpm -ivh --nodeps MySQL-client-community-5.0.67-0.rhel4.i386.rpm

输入命令:mysql -uroot -proot 按回车出现:
Enter password:
这里让输入密码,由于还没有为root用户设置密码,所以直接按回车进入mysql客户端:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.67-community MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
为mysql的root用户设置密码:参考安装myql数据库服务器过程中的提示,
进入/usr/bin目录
然后输入: mysqladmin -uroot password 'root'即可 注:这里我将密码也设置为root
再次登录mysql:mysql -uroot -proot 按回车即可

四、设置tomcat在系统启动时候自动启动

编辑rc.local文件 vi /etc/rc.d/rc.local
添加以下内容:
export JAVA_HOME=/usr/java/jdk1.6.0_10 --注:jdk安装目录
export TOMCAT_HOME=/usr/local/apache-tomcat-6.0.18 --注:tomcat安装目录
/usr/local/apache-tomcat-6.0.18/bin/startup.sh --注:tomcat启动脚本的绝对目录
重启机子即可
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值