centos install python and jdk

install python

#zip package installation
[root@china ~]# yum -y install zlib*
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                             | 3.7 kB     00:00     
extras                                                                                                                           | 3.4 kB     00:00     
updates                                                                                                                          | 3.4 kB     00:00     
Setting up Install Process
Package zlib-1.2.3-29.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be installed
---> Package zlib-static.x86_64 0:1.2.3-29.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================
 Package                                Arch                              Version                                 Repository                       Size
========================================================================================================================================================
Installing:
 zlib-devel                             x86_64                            1.2.3-29.el6                            base                             44 k
 zlib-static                            x86_64                            1.2.3-29.el6                            base                             52 k

Transaction Summary
========================================================================================================================================================
Install       2 Package(s)

Total download size: 96 k
Installed size: 227 k
Downloading Packages:
(1/2): zlib-devel-1.2.3-29.el6.x86_64.rpm                                                                                        |  44 kB     00:00     
(2/2): zlib-static-1.2.3-29.el6.x86_64.rpm                                                                                       |  52 kB     00:00     
--------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                   366 kB/s |  96 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : zlib-devel-1.2.3-29.el6.x86_64                                                                                                       1/2 
  Installing : zlib-static-1.2.3-29.el6.x86_64                                                                                                      2/2 
  Verifying  : zlib-devel-1.2.3-29.el6.x86_64                                                                                                       1/2 
  Verifying  : zlib-static-1.2.3-29.el6.x86_64                                                                                                      2/2 

Installed:
  zlib-devel.x86_64 0:1.2.3-29.el6                                           zlib-static.x86_64 0:1.2.3-29.el6                                          



#python installation

[root@china python_tools]# ll
Total usage 22180 -rw - 
r-- r-- 1 root root 22710891 May    2  06:15 Python - 3.6.4.tgz
[root@china python_tools]#
[root@china python_tools]#
[root@china python_tools]#
#Open the terminal with root privileges, enter the storage path of the installation package, and decompress the installation package:
[root@china python_tools]# tar -xzvf Python-3.6.4.tgz 
#Enter the path of the decompressed installation package:
[root@china python_tools]# cd Python-3.6.4

#Compile the installation package, specify the installation path, and execute the installation command:
#Note: The prefix parameter is used to specify that Python is installed in a new directory to prevent overwriting the system's default installed python
[root@china Python-3.6.4]# ./configure --prefix=/usr/local/python36
[root@china Python - 3.6 . 4 ]# make && make  install #Modify the 
default Python path of the system, because the default Python 2.6.6 point when entering a Python command in the terminal 
[root@china Python - 3.6 . 4 ]# mv / usr/bin/python /usr/bin/python-2.6.6 makes a new symlink , pointing 
to Python - 3.6.0 :
Note: python36 here is the installation path specified in step 4, python3.6 is the executable program in the Python package
[root@china Python-3.6.4]# ln -s /usr/local/python36/bin/python3.6 /usr/bin/python
[root@china Python-3.6.4]# python
Python 3.6.4 (default, May  2 2018, 06:22:39) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type " help " , " copyright " , " credits " or " license "  for  more information.
 >>> 
 7 . Because yum depends on python, here we modify the default python, we need to modify yum to make it run To point to an older version:
 vi /usr/bin/ yum   
put "# !/usr/bin/ python" in the first line
Modify it to "# ! /usr/bin/python-2.6.6 " and save it

 

install java

[root@china javatools]# chmod a+x jdk-6u45-linux-i586.bin 
[root@china javatools]# ./jdk-6u45-linux-i586.bin 
#Modify the jdk directory
[root@china javatools]# mv jdk1.6.0_45/ /usr/java/jdk1.6.0_45
[root@china javatools]# ls
jdk-6u45-linux-i586.bin
[root@china javatools]# cd /usr/java/
[root@china java]# ls
jdk1.6.0_45
[root@china java]# cd jdk1.6.0_45/
#Set environment variables
vi /etc/profile 
Add at the end:
##use for JAVA 1.6 
JAVA_HOME=/usr/java/jdk1.6.0_45; 
PATH=$JAVA_HOME/bin:$PATH; 
CLATHPATH=.:$JAVA_HOME/lib; 
export JAVA_HOME PATH CLATHPATH;
Check whether the environment variable is set successfully:
echo $JAVA_HOME 
echo $PARH 
echo $CLATHPATH
Check if jdk is installed successfully
[root@china jdk1.6.0_45]# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Server VM (build 20.45-b01, mixed mode)
[root@china jdk1.6.0_45]# javac
Usage: javac <options> <source file>
Among them, possible options include:
  - g generates all debug info
   - g:none generates no debug info
   - g:{lines,vars,source} generates only some debug info
   - nowarn doesn't generate any warnings
   -verbose outputs a message about what the compiler is doing

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325359325&siteId=291194637