[TOC]
由于各Linux开发厂商的不同,因此不同开发厂商的Linux版本操作细节也不一样,今天就来说一下CentOS下JDK的安装:
# 方法一:手动解压JDK的压缩包,然后设置环境变量
1.在/usr/目录下创建java目录
```
[root@localhost ~]# mkdir/usr/java
[root@localhost ~]# cd /usr/java
```
2.下载jdk,然后解压
```
[root@localhost java]# curl -O http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz
[root@localhost java]# tar -zxvf jdk-7u79-linux-x64.tar.gz
```
3.设置环境变量
```
[root@localhost java]# vi /etc/profile
```
在profile中添加如下内容:
```
#set java environment
JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
```
让修改生效:
```
[root@localhost java]# source /etc/profile
```
4.验证JDK有效性
```
[root@localhost java]# 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)
```
# 方法二:用yum安装JDK
1.查看yum库中都有哪些jdk版本(暂时只发现了openjdk)
```
[root@localhost ~]# yum search java|grep jdk
ldapjdk-javadoc.x86_64 : Javadoc for ldapjdk
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
ldapjdk.x86_64 : The Mozilla LDAP Java SDK
```
2.选择版本,进行安装
```
//选择1.7版本进行安装
[root@localhost ~]# yum install java-1.7.0-openjdk
```
//安装完之后,默认的安装目录是在: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
3.设置环境变量
```
[root@localhost ~]# vi /etc/profile
```
在profile文件中添加如下内容
```
#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
```
让修改生效
```
[root@localhost java]# source /etc/profile
```
4.验证(同上一方法)
# 方法三:用rpm安装JDK
1.下载rpm安装文件
```
[root@localhost ~]$ curl -O http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm
```
2.使用rpm命令安装
```
[root@localhost ~]# rpm -ivh jdk-7u79-linux-x64.rpm
```
3.设置环境变量
```
[root@localhost java]# vi /etc/profile
```
在打开的profile文件中添加如下内容:
```
#set java environment
JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
```
让修改生效
```
[root@localhost java]# source /etc/profile
```
4.验证(同上一方法)
注:和yum安装类似,不用设置环境变量就可以运行java命令。rpm安装方式默认会把jdk安装到/usr/java/jdk1.7.0_79,然后通过三层链接,链接到/usr/bin,具体链接如下:
```
[root@localhost ~]# cd /bin
[root@localhost bin]# ll|grep java
lrwxrwxrwx. 1 root root 25 Mar 28 11:24 jar ->/usr/java/default/bin/jar
lrwxrwxrwx. 1 root root 26 Mar 28 11:24 java -> /usr/java/default/bin/java
lrwxrwxrwx. 1 root root 27 Mar 28 11:24 javac ->/usr/java/default/bin/javac
lrwxrwxrwx. 1 root root 29 Mar 28 11:24 javadoc ->/usr/java/default/bin/javadoc
lrwxrwxrwx. 1 root root 28 Mar 28 11:24 javaws ->/usr/java/default/bin/javaws
lrwxrwxrwx. 1 root root 30 Mar 28 11:24 jcontrol ->/usr/java/default/bin/jcontrol
[root@localhost bin]# cd /usr/java/
[root@localhost java]# ll
total 4
lrwxrwxrwx. 1 root root 16 Mar 28 11:24 default-> /usr/java/latest
drwxr-xr-x. 8 root root 4096 Mar 28 11:24 jdk1.7.0_79
lrwxrwxrwx. 1 root root 21 Mar 28 11:24 latest -> /usr/java/jdk1.7.0_79
```
# 方法四:Ubuntu 上使用apt-get安装JDK
1.查看apt库都有哪些jdk版本
```
root@Itble:~# apt-cache search java|grep jdk
default-jdk - Standard Java or Java compatible Development Kit
default-jdk-doc - Standard Java or Java compatible Development Kit (documentation)
gcj-4.6-jdk - gcj and classpath development tools for Java(TM)
gcj-jdk - gcj and classpath development tools for Java(TM)
openjdk-6-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-6-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-6-doc - OpenJDK Development Kit (JDK) documentation
openjdk-6-jdk - OpenJDK Development Kit (JDK)
openjdk-6-jre-lib - OpenJDK Java runtime (architecture independent libraries)
openjdk-6-source - OpenJDK Development Kit (JDK) source files
openjdk-7-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-7-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-7-doc - OpenJDK Development Kit (JDK) documentation
openjdk-7-jdk - OpenJDK Development Kit (JDK)
openjdk-7-source - OpenJDK Development Kit (JDK) source files
uwsgi-plugin-jvm-openjdk-6 - Java plugin for uWSGI (OpenJDK 6)
uwsgi-plugin-jwsgi-openjdk-6 - JWSGI plugin for uWSGI (OpenJDK 6)
openjdk-6-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-6-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-7-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-7-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-7-jre-lib - OpenJDK Java runtime (architecture independent libraries)
```
2.选择版本进行安装
```
root@Itble:~# apt-get install openjdk-7-jdk
```
3.设置环境变量
```
root@Itble:~# vi /etc/profile
```
在打开的profile文件中添加如下内容
```
#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
```
让修改生效
```
root@Itble:~# source /etc/profile
```
4.验证(同上一方法)
- centos
- 安装工具
- 安装nginx
- 安装PHP5
- 安装PHP7.0.1
- 安装PHP7.0.8
- 安装redis
- redis允许远程访问
- 安装php之redis扩展
- 安装mysql
- 配置nginx虚拟机绑定域名
- xdebug下载配置
- phpStorm远程调试配置
- 报错解决:安装PHP7解决问题方法
- 报错解决:xdebug-解决问题
- yum丢失的解决办法
- CentOS下安装JDK的四种方法
- workman
- 某服务器配置情况
- 安装PHP7.2.17
- 安装PHP7.1.27
- 安装MongoDB
- ubuntu
- mac
- window
- phpstrom+wamp+xdebug
- mysql
- MySql创建本地用户和远程用户 并赋予权限
- 自建主从复制-mycat
- 数据库优化
- 阿里云mysql主从复制
- 报错解决
- SQL分析
- group by
- Mysql定时备份数据脚本
- MySQL数据库远程连接开启方法
- 启动报错systemctl status
- 日志导出
- mysq进程
- mysql查询正在执行的进程
- 命令
- nginx
- 安装GIT
- access.log
- error.log分析
- 500 Internal Server Error错误
- 502解决方案
- 405 Not Allowed,nginx静态文件响应post请求
- Linux基本操作
- 创建用户
- chmod命令详细用法设置文件的权限
- chown命令
- chgrp命令:改变文件的群组
- Linux 设置定时任务crontab命令
- 其他问题
- Win10 Subsystem Linux : Ubuntu 的root密码
- 安全问题
- PHP安全设置
- redis
- 安装
- 安装2.8.17
- 问题
- 日志分析
- an upstream response is buffered to a temporary file
- too many open files
- worker_connections are not enough
- recv() failed
- 日志
- 系统日志
- apache访问日志与错误日志
- nginx访问日志与错误日志
- php错误日志
- php-fpm慢日志
- mysql慢日志
- 服务器优化
- php-fpm进程数优化
- 服务器安全
- RHSA-2018:2748: kernel security and bug fix update
- RHSA-2018:3408: git security update
- RHSA-2018:2570: bind security update
- RHSA-2018:3052: wget security and bug fix update
- RHSA-2018:3221: openssl security, bug fix, and enhancement update
- RHSA-2018:2384: kernel security and bug fix update
- RHSA-2018:3032: binutils security, bug fix, and enhancement update
- RHSA-2018:3157: curl and nss-pem security and bug fix update
- RHSA-2018:2285: yum-utils security update
- RHSA-2018:3092: glibc security, bug fix, and enhancement update
- CVE-2018-17182 on Ubuntu 14.04 LTS (trusty)
- CVE-2018-9415 on Ubuntu 14.04 LTS (trusty)
- CVE-2018-8043 on Ubuntu 14.04 LTS (trusty)
- CVE-2018-3620 on Ubuntu 14.04 LTS (trusty)
- CVE-2018-14634 on Ubuntu 14.04 LTS (trusty)
- CVE-2018-14609 on Ubuntu 14.04 LTS (trusty)
- CentOS Linux 7安全基线检查
- Redis安全基线检查
- RHSA-2019:1168-重要: 内核 安全更新
- RHSA-2019:1481-重要: 内核 安全更新
- RHSA-2019:0512-重要: 内核 安全和BUG修复更新
- ThinkPHP漏洞
- ThinkPHP 5.1.X <= 5.1.30 远程代码执行漏洞
- ThinkPHP 5 <=5.0.22 远程代码执行高危漏洞
- ThinkPHP <5.0.24 Request.php 远程代码执行漏洞
- PHP
- 怎样获取PHP各种版本
- 攻击
- SSH暴力破解
- RDP暴力破解
- SQLSERVER暴力破解
- MYSQL暴力破解
- FTP暴力破解
- SQL注入
- 代码执行
- XSS攻击
- 本地文件包含
- 远程文件包含
- 脚本木马
- 上传漏洞
- 路径遍历
- 越权访问
- CSRF
- CRLF
- 其他