`
cloudtech
  • 浏览: 4605342 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

linux下javaEE环境搭建(java6 mysql5 tomcat6 myeclipse8.0 安装过程及常见问题) linux下javaEE环境搭建(java6 mysql5 tomcat6 myeclipse8.0 安装过程及常见问题)

 
阅读更多

linux下javaEE环境搭建(java6 mysql5 tomcat6 myeclipse8.0 安装过程及常见问题)

分类:技术文章892人阅读评论(0)收藏举报

javaEE环境包括:
java(jdk)的安装:
这个是必须安装的,安装完成后,它给我们提供一个java运行环境jre。首先到官网下载:
jdk-6u21-linux-i586-rpm.bin
安装命令:rpm -ivh jdk-6u21-linux-i586-rpm.bin
正常情况下:将会被安装到/usr/java/jdk1.6.0_21
安装好后还需要配置环境变量:关于环境变量可以修改2个文件,1是:/etc/profile,这个文件是对所有用户适用的,也就是说每个用户都会加载这个文件。2是:某个用户下的.bash_profile,这个文件是某个用户独有的。
修改第一个文件,会带来安全问题,而修改第二个文件后,只有这个用户才能加载相应的环境变量信息。
我比较习惯修改第一个文件。下面是修改的地方(在done后面添加):
JAVA_HOME=/usr/java/jdk1.6.0_21
PATH=$JAVA_HOME/bin:$PKG_CONFIG_PATH:$PATH
CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
需要说明的是:在windows下,用;隔开,而linux则是: 从java6开始好像可以不配CLASSPATH。
然后运行javac可以看到一些信息。用java -version 可以看到版本信息如下:
[root@localhost ~]# java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Server VM (build 17.0-b16, mixed mode)
到此javajdk安装成功。
mysql/oracle的安装:
数据库的安装,首先下载安装包:mysql-5.0.87-linux-i686-glibc23.tar.zip
解压:unzip mysql-5.0.87-linux-i686-glibc23.tar.zip
修改权限:chmod 777 mysql-5.0.87-linux-i686-glibc23.tar.gz
新建mysql组:groupadd mysql
创建mysql用户,并将其放到mysql组中: useradd -g mysql mysql
(进入到mysql的文件夹)初始化数据库:scripts/mysql_install_db --user=mysql
初始化成功后看到如下信息:
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
./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.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com

说明安装成功。
在mysql文件夹下,修改所有文件及文件的所有者和所在组:
chown -R root .
将data文件夹的所有者修改为mysql用户:chown -R mysql data
修改所在组:chgrp -R mysql .

启动mysql:bin/mysqld_safe --user=mysql &
测试是否安装好:
1.netstat -anp |more 如果发现监听3306端口说明成功。
2.进入mysql: ./bin/mysql -u root -p会出现:
Enter password:
直接回车,因为没有设置密码。

出现如下则正常运行:
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 1
Server version: 5.0.87 MySQL Community Server (GPL)

Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

关闭mysql: mysqladmin -u root -p shutdown
配置环境变量,让这些命令可以在任何目录下执行:这次修改root用户独有的配置文件/root/.bash_profile

将mysql安装好的文件夹copy到/usr/local下,
在.bash_profile
mysql_path=/usr/mysql/bin
PATH=$PATH:$HOME/bin:$mysql_path
这样就ok了。
tomcat/其他web容器的安装:
tomcat版本为:apache-tomcat-6.0.29.tar.gz
解压:tar -zxvf apache-tomcat-6.0.29.tar.gz
配置环境变量:(首先将其copy到/usr/local下)
打开.bash_profile :gedit .bash_profile
# User specific environment and startup programs
tomcat_path=/usr/local/tomcat6.0.29/bin
mysql_path=/usr/mysql/bin
PATH=$PATH:$HOME/bin:$mysql_path:$tomcat_path


#export mysql_path

export PATH
unset USERNAME
测试:
[root@localhost ~]# startup.sh
Using CATALINA_BASE: /usr/local/tomcat6.0.29
Using CATALINA_HOME: /usr/local/tomcat6.0.29
Using CATALINA_TMPDIR: /usr/local/tomcat6.0.29/temp
Using JRE_HOME: /usr/java/jdk1.6.0_21
Using CLASSPATH: /usr/local/tomcat6.0.29/bin/bootstrap.jar
[root@localhost ~]# shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat6.0.29
Using CATALINA_HOME: /usr/local/tomcat6.0.29
Using CATALINA_TMPDIR: /usr/local/tomcat6.0.29/temp
Using JRE_HOME: /usr/java/jdk1.6.0_21
Using CLASSPATH: /usr/local/tomcat6.0.29/bin/bootstrap.jar

myeclipse/eclipse的安装:

myeclipse安装包:myeclipse-8.0.0-linux-gtk-x86.tgz
修改权限:chmod 777 myeclipse-8.0.0-linux-gtk-x86.tgz
解压:tar -zxvf myeclipse-8.0.0-linux-gtk-x86.tgz
安装:./myeclipse-8-stable-installer

安装完成后,添加一个shell文件。
名字:myeclipse.sh
内容:/root/Genuitec/MyEclipse/ 8.x/ Latest/myeclipse vm java -data workplace

/root/Genuitec/MyEclipse/ 8.x/ Latest/myeclipse是myeclipse启动的全路径 vm为指定运行的虚拟机,由于配置了环境变量,所以不用些全路径 -data workplace指定工程的目录。如果不指定,myeclipse也会提示你指定。

javaEE环境包括:
java(jdk)的安装:
这个是必须安装的,安装完成后,它给我们提供一个java运行环境jre。首先到官网下载:
jdk-6u21-linux-i586-rpm.bin
安装命令:rpm -ivh jdk-6u21-linux-i586-rpm.bin
正常情况下:将会被安装到/usr/java/jdk1.6.0_21
安装好后还需要配置环境变量:关于环境变量可以修改2个文件,1是:/etc/profile,这个文件是对所有用户适用的,也就是说每个用户都会加载这个文件。2是:某个用户下的.bash_profile,这个文件是某个用户独有的。
修改第一个文件,会带来安全问题,而修改第二个文件后,只有这个用户才能加载相应的环境变量信息。
我比较习惯修改第一个文件。下面是修改的地方(在done后面添加):
JAVA_HOME=/usr/java/jdk1.6.0_21
PATH=$JAVA_HOME/bin:$PKG_CONFIG_PATH:$PATH
CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
需要说明的是:在windows下,用;隔开,而linux则是: 从java6开始好像可以不配CLASSPATH。
然后运行javac可以看到一些信息。用java -version 可以看到版本信息如下:
[root@localhost ~]# java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Server VM (build 17.0-b16, mixed mode)
到此javajdk安装成功。
mysql/oracle的安装:
数据库的安装,首先下载安装包:mysql-5.0.87-linux-i686-glibc23.tar.zip
解压:unzip mysql-5.0.87-linux-i686-glibc23.tar.zip
修改权限:chmod 777 mysql-5.0.87-linux-i686-glibc23.tar.gz
新建mysql组:groupadd mysql
创建mysql用户,并将其放到mysql组中: useradd -g mysql mysql
(进入到mysql的文件夹)初始化数据库:scripts/mysql_install_db --user=mysql
初始化成功后看到如下信息:
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
./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.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com

说明安装成功。
在mysql文件夹下,修改所有文件及文件的所有者和所在组:
chown -R root .
将data文件夹的所有者修改为mysql用户:chown -R mysql data
修改所在组:chgrp -R mysql .

启动mysql:bin/mysqld_safe --user=mysql &
测试是否安装好:
1.netstat -anp |more 如果发现监听3306端口说明成功。
2.进入mysql: ./bin/mysql -u root -p会出现:
Enter password:
直接回车,因为没有设置密码。

出现如下则正常运行:
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 1
Server version: 5.0.87 MySQL Community Server (GPL)

Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

关闭mysql: mysqladmin -u root -p shutdown
配置环境变量,让这些命令可以在任何目录下执行:这次修改root用户独有的配置文件/root/.bash_profile

将mysql安装好的文件夹copy到/usr/local下,
在.bash_profile
mysql_path=/usr/mysql/bin
PATH=$PATH:$HOME/bin:$mysql_path
这样就ok了。
tomcat/其他web容器的安装:
tomcat版本为:apache-tomcat-6.0.29.tar.gz
解压:tar -zxvf apache-tomcat-6.0.29.tar.gz
配置环境变量:(首先将其copy到/usr/local下)
打开.bash_profile :gedit .bash_profile
# User specific environment and startup programs
tomcat_path=/usr/local/tomcat6.0.29/bin
mysql_path=/usr/mysql/bin
PATH=$PATH:$HOME/bin:$mysql_path:$tomcat_path


#export mysql_path

export PATH
unset USERNAME
测试:
[root@localhost ~]# startup.sh
Using CATALINA_BASE: /usr/local/tomcat6.0.29
Using CATALINA_HOME: /usr/local/tomcat6.0.29
Using CATALINA_TMPDIR: /usr/local/tomcat6.0.29/temp
Using JRE_HOME: /usr/java/jdk1.6.0_21
Using CLASSPATH: /usr/local/tomcat6.0.29/bin/bootstrap.jar
[root@localhost ~]# shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat6.0.29
Using CATALINA_HOME: /usr/local/tomcat6.0.29
Using CATALINA_TMPDIR: /usr/local/tomcat6.0.29/temp
Using JRE_HOME: /usr/java/jdk1.6.0_21
Using CLASSPATH: /usr/local/tomcat6.0.29/bin/bootstrap.jar

myeclipse/eclipse的安装:

myeclipse安装包:myeclipse-8.0.0-linux-gtk-x86.tgz
修改权限:chmod 777 myeclipse-8.0.0-linux-gtk-x86.tgz
解压:tar -zxvf myeclipse-8.0.0-linux-gtk-x86.tgz
安装:./myeclipse-8-stable-installer

安装完成后,添加一个shell文件。
名字:myeclipse.sh
内容:/root/Genuitec/MyEclipse/ 8.x/ Latest/myeclipse vm java -data workplace

/root/Genuitec/MyEclipse/ 8.x/ Latest/myeclipse是myeclipse启动的全路径 vm为指定运行的虚拟机,由于配置了环境变量,所以不用些全路径 -data workplace指定工程的目录。如果不指定,myeclipse也会提示你指定。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics