Centos6.8 安装JDK1.7
检查Linux系统是否已安装jdk
rpm -qa | grep java
tzdata-java-2016c-1.el6.noarch
java-1.6.0-openjdk-1.6.0.38-1.13.10.4.el6.x86_64
java-1.7.0-openjdk-1.7.0.99-2.6.5.1.el6.x86_64
卸载系统自带的java
rpm -qa | grep java | xargs rpm -e --nodeps
查看卸载结果
java -version
bash: /usr/bin/java: No such file or directory
卸载成功后,下载jdk
http://www.[Oracle](http://www.linuxidc.com/topicnews.aspx?tid=12 "Oracle").com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
jdk-7u79-linux-x64.rpm or jdk-7u79-linux-x64.tar.gz
第一种方法:rpm包安装
rpm包导入用户root目录下
ls
出现文件:
jdk-7u79-linux-x64.rpm
赋予权限
chmod 755 jdk-7u79-linux-x64.rpm
安装
rpm -ivh jdk-7u79-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
安装完成
第二种方法:二进制包安装
建立JAVA_HOME目录
mkdir /usr/java
将二进制包放在 /usr/java/
下并解压
mv jdk-7u79-linux-x64.tar.gz /usr/java
cd /usr/java
tar xvf jdk-7u79-linux-x64.tar.gz
查看结果
ls
出现文件
jdk1.7.0_79 jdk-7u79-linux-x64.tar.gz
为了节省空间,可以将二进制包删去
rm -rf jdk-7u79-linux-x64.tar.gz
配置全局java环境变量
vi /etc/profile
最后面添加
export JAVA_HOME=/usr/java/jdk1.7.0_79
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
wq保存退出
使profile配置生效
source /etc/profile
配置用户java环境变量
vi ~/.bashrc
export JAVA_HOME=/usr/java/jdk1.7.0_79
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
使bashrc配置生效
source ~/.bashrc
检查一下环境变量
echo $JAVA_HOME
/usr/java/jdk1.7.0_79
echo $CLASSPATH
./:/usr/java/jdk1.7.0_79/lib:/usr/java/jdk1.7.0_79/jre/lib
[root@linux3 java]# echo $PATH
/usr/local/cmake-2.8.10.2/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/local/cmake-2.8.10.2/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.7.0_79/bin:/usr/java/jdk1.7.0_79/bin
安装完成
最后检测一下已经安装的jdk
java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
或者输入 javac
mysql一些命令备忘
//mysql
netstat -tunlp | grep :3306
netstat -ntlp
service mysqld stop
ps -A | grep mysql
kill -9 x x
service mysqld start
/usr/bin/mysqld_safe --skip-grant-tables
service iptables restart
关闭防火墙
/etc/init.d/iptables stop
start 开启
restart 重启
永久性关闭防火墙chkconfig --level 35 iptables off
//使java环境变量生效
source /etc/profile.d/P.sh
echo $JRE_HOME
//tomcat
/usr/local/tomcat/bin/startup.sh
-
安装Tomcat
类似的步骤向上:下载Tomcat + 将Tomcat上传到云服务器/usr/local/文件夹tar -zxf apache-tomcat-7.0.70.tar.gz mv apache-tomcat-7.0.70.tar.gz tomcat
-
安装MySQL
-
检测系统是否自带mysql
yum list installed | grep mysql
-
删除系统自带的mysql及其依赖命令
yum -y remove mysql-libs.x86_64
-
给CentOS添加rpm源,并且选择较新的源命令:
wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm yum localinstall mysql-community-release-el6-5.noarch.rpm yum repolist all | grep mysql yum-config-manager --disable mysql55-community yum-config-manager --disable mysql56-community yum-config-manager --enable mysql57-community-dmr yum repolist enabled | grep mysql
-
安装mysql 服务器命令
yum install mysql-community-server
-
启动mysql命令
service mysqld start
-
-
见证成果的时候
-
启动tomcat
/usr/local/tomcat/bin/startup.sh
-