rpm包一般都有默認(rèn)的安裝路徑,如何你要更改默認(rèn)路徑,有沒(méi)有辦法呢?當(dāng)然有。我們來(lái)看下面的例子。
創(chuàng)新互聯(lián)從2013年開(kāi)始,先為新興等服務(wù)建站,新興等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為新興企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。比如在安裝JDK (Java Development Kit)或JRE (Java Runtime Environment)時(shí),這個(gè)Redhat package文件的默認(rèn)安裝路徑是/usr/java。如果你要安裝在其它路徑下,例如要放到/home/java目錄下,該如何做呢?
一、首先查看rpm包的詳細(xì)信息
[root@oracle ~]# rpm -qpi jdk-6u43-linux-amd64.rpm
Name : jdk Relocations: /usr/java
Version : 1.6.0_43 Vendor: Oracle and/or its affiliates.
Release : fcs Build Date: Fri 01 Mar 2013 09:03:27 PM CST
Install Date: (not installed) Build Host: jb6-lin-amd64.sfbay.sun.com
Group : Development/Tools Source RPM: jdk-1.6.0_43-fcs.src.rpm
Size : 127075557 License: Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. Also under other license(s) as shown at the Description field.
Signature : (none)
Packager : Java Software
URL : http://www.oracle.com/technetwork/java/javase/overview/index.html
Summary : Java(TM) Platform Standard Edition Development Kit
Description :
The Java Platform Standard Edition Development Kit (JDK) includes both
the runtime environment (Java virtual machine, the Java platform classes
and supporting files) and development tools (compilers, debuggers,
tool libraries and other tools).
The JDK is a development environment for building applications, applets
and components that can be deployed with the Java Platform Standard
Edition Runtime Environment.
這個(gè)JDK是默認(rèn)要裝在/usr/java 下的。
下面我們這樣來(lái)設(shè)置參數(shù),就可以把JDK裝在你指定的目錄下。
[root@sharesan ~]# rpm -i --badreloc --relocate /usr/java=/home/java jdk-6u43-linux-amd64.rpm
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
ln: creating symbolic link `/usr/java/jdk1.6.0_43': No such file or directory
參數(shù)釋義:
badreloc是強(qiáng)制把文件安裝到你想要的地方。
relocate就是只把應(yīng)該裝到oldpath下的文件安裝到newpath,實(shí)現(xiàn)將一部分文件安裝到其它的路徑,而不是把所有的這個(gè)包的文件都替換。
但是無(wú)論是prefix還是relocate都不見(jiàn)得可以真正可以用,因?yàn)橛械陌蛘呶募辉试S裝到其他路徑,比如oracleasm-support-2.1.8-1.el6.x86_64.rpm
[root@oracle ~]# rpm -qpi oracleasm-support-2.1.8-1.el6.x86_64.rpm
warning: oracleasm-support-2.1.8-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Name : oracleasm-support Relocations: (not relocatable)
Version : 2.1.8 Vendor: Oracle Corporation
Release : 1.el6 Build Date: Sat 09 Feb 2013 06:46:49 AM CST
Install Date: (not installed) Build Host: ca-build44.us.oracle.com
Group : System Environment/Kernel Source RPM: oracleasm-support-2.1.8-1.el6.src.rpm
Size : 221696 License: GPL
Signature : RSA/8, Sat 09 Feb 2013 06:50:30 AM CST, Key ID 72f97b74ec551f03
Packager : Joel Becker
URL : http://oss.oracle.com/projects/oracleasm/
Summary : The Oracle Automatic Storage Management support programs.
Description :
Tools to manage the Oracle Automatic Storage Management library driver
not relocatable不能重定位,是無(wú)法修改安裝目錄的,只有去掉 --prefix參數(shù)了。
[root@sharesan ~]# java -version
-bash: /usr/bin/java: No such file or directory
這時(shí)沒(méi)有顯示JAVA版本號(hào),是因?yàn)榄h(huán)境變量還沒(méi)修改。
下面修改一下JAVA的環(huán)境變量
[root@sharesan jdk1.6.0_43]# vi /etc/profile
JAVA_HOME=/home/java/jdk1.6.0_43
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
"/etc/profile" 85L, 1961C written
[root@sharesan jdk1.6.0_43]# source /etc/profile
使環(huán)境變量生效。
再查看,就有JAVA版本號(hào)顯示了。
[root@sharesan jdk1.6.0_43]# java -version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
補(bǔ)充一下:
在安裝JDK時(shí),需要查看一下原系統(tǒng)是否有其他的JAVA版本號(hào),如果跟你要裝的不一致,請(qǐng)卸載后再裝。
[root@sharesan ~]# java -version
java version "1.7.0_45"
OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
進(jìn)行查找
[root@sharesan ~]# rpm -aq |grep java
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
tzdata-java-2013g-1.el6.noarch
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
強(qiáng)制卸載
[root@sharesan ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
[root@sharesan ~]# rpm -aq |grep java
tzdata-java-2013g-1.el6.noarch
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
[root@sharesan ~]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
再檢查,發(fā)現(xiàn)已卸載干凈。
[root@sharesan ~]# java -version
-bash: /usr/bin/java: No such file or directory
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。