1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - Linux系统 - centos - 正文

君子好学,自强不息!

centos安装python与jdk

2023-02-24 | centos | gtxyzz | 6433°c
A+ A-

安装python

#压缩包安装
[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安装

[root@china python_tools]# ll
总用量 22180
-rw-r--r-- 1 root root 22710891 5月   2 06:15 Python-3.6.4.tgz
[root@china python_tools]# 
[root@china python_tools]# 
[root@china python_tools]# 
#以root权限打开终端,进入安装包的存放路径,解压安装包:
[root@china python_tools]# tar -xzvf Python-3.6.4.tgz 
#进入解压好的安装包路径:
[root@china python_tools]# cd Python-3.6.4

#编译安装包,指定安装路径,并执行安装命令: 
#注意:prefix参数用于指定将Python安装在新目录,防止覆盖系统默认安装的python
[root@china Python-3.6.4]# ./configure --prefix=/usr/local/python36
[root@china Python-3.6.4]# make && make install
#修改系统默认的Python路径,因为在终端中输入Python命令时默认是指向Python2.6.6
[root@china Python-3.6.4]# mv /usr/bin/python /usr/bin/python-2.6.6
建立新的软连接,指向Python-3.6.0: 
注:这里的python36是第4步指定的安装路径,python3.6是Python包里的可执行程序
[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、因为yum是依赖python的,所以这里我们修改了默认的python,就要要修改yum,让其运行指向旧的版本:
vi /usr/bin/yum  
将第一行中的“#!/usr/bin/python”
修改为“#!/usr/bin/python-2.6.6”,保存即可

安装pip

解决pip is configured with locations that require TLS/SSL问题

yum install openssl openssl-devel

[root@china Python-3.6.4]# rpm -qa|grep openssl
openssl-devel-1.0.1e-57.el6.x86_64
openssl098e-0.9.8e-17.el6.centos.2.x86_64
openssl-1.0.1e-57.el6.x86_64

cd /root/python_tools/Python-3.6.4/Modules
vim Setup
#修改配置


# Socket module helper for socket(2)
_socket socketmodule.c


#SSL=/usr/local/ssl
_ssl _ssl.c \
        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
        -L$(SSL)/lib -lssl -lcrypto


修改完毕后保存。
# 重新编译
[root@china Python-3.6.4]# make && make install

[root@china Python-3.6.4]# python3
Python 3.6.4 (default, May  9 2018, 20:35:48) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
[root@china Python-3.6.4]# pip3 install lxml
Collecting lxml
Downloading https://files.pythonhosted.org/packages/a7/b9/ccf46cea0f698b40bca2a9c1a44039c336fe1988b82de4f7353be7a8396a/lxml-4.2.1-cp36-cp36m-manylinux1_x86_64.whl (5.6MB)
100% |████████████████████████████████| 5.7MB 38kB/s 
Installing collected packages: lxml
Successfully installed lxml-4.2.1

 

centos安装python与jdk

 

安装java

[root@china javatools]# chmod a+x jdk-6u45-linux-i586.bin 
[root@china javatools]# ./jdk-6u45-linux-i586.bin 
#修改jdk目录
[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/
#设置环境变量
vi /etc/profile 
在最后加上:

##use for JAVA 1.6

JAVA_HOME=/usr/java/jdk1.6.0_45
PATH=$JAVA_HOME/bin:$PATH
CLATHPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export JAVA_HOME PATH CLATHPATH

检查环境变量是否配成功: 
echo $JAVA_HOME 
echo $PARH 
echo $CLATHPATH
检查jdk是否安装成功
[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
用法:javac <选项> <源文件>
其中,可能的选项包括:
  -g                         生成所有调试信息
  -g:none                    不生成任何调试信息
  -g:{lines,vars,source}     只生成某些调试信息
  -nowarn                    不生成任何警告
  -verbose                   输出有关编译器正在执行的操作的消息

 

升级openssl(拓展)

wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz

tar xzvf openssl-1.0.2h.tar.gz

cd openssl-1.0.2h

./config --prefix=/usr shared zlib-dynamic

#提醒需要在build之前做make depend
make depend

rm -f /usr/bin/openssl
rm -f /usr/include/openssl
make && make install
ln -sf /usr/include/openssl/*.h /usr/include/
ln -sf /usr/lib/openssl/engines/*.so /usr/lib/
ldconfig -v

openssl version -a
[root@china bin]# openssl version -a
OpenSSL 1.0.2h  3 May 2016
built on: reproducible build, date unspecified
platform: linux-x86_64

 

本文来源:1818IP

本文地址:https://www.1818ip.com/post/32499.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。