使用mv命令备份文件,一般在文件后面加.backup
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-Debuginfo.repo CentOS-Media.repo
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup
[root@localhost yum.repos.d]# ls
CentOS-Base.repo.backup CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-Debuginfo.repo CentOS-Media.repo
[root@localhost yum.repos.d]# rm -rf *.repo
[root@localhost yum.repos.d]# ls
CentOS-Base.repo.backup
下载前先安装 wget
命令:yum -y install wget
163源镜像地址
CentOS7_repo下载
命令下载
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
CentOS6_repo下载
命令下载
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
CentOS5_repo下载
命令下载
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS5-Base-163.repo
阿里云源镜像地址
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
运行以下命令生成缓存
yum clean all
yum makecache
Python Source Releases
wget -O /home/Python-3.7.1.tgz https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
打开下载目录:
cd /home
解压命令:tar -zxvf Python-3.7.1.tgz
命令:
yum -y install gcc openssl-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite sqlite-devel readline-devel tk tk-devel gdbm gdbm-devel db4-devel libpcap-devel lzma xz xz-devel libuuid-devel libffi-devel perl zlib* opensll*
安装openssl缺少perl5会出现下面的错误,所以要先安装Perl5
Operating system: x86_64-whatever-linux2You need Perl 5.
perl-5.28.0.tar.gz
官网安装帮助文档
wget https://www.cpan.org/src/5.0/perl-5.28.0.tar.gz tar -xzf perl-5.28.0.tar.gz cd perl-5.28.0 ./Configure -des -Dprefix=$HOME/localperl make make test make install
下载:
wget -O /home/perl-5.28.0.tar.gz https://www.cpan.org/src/5.0/perl-5.28.0.tar.gz
解压:tar -zxvf perl-5.28.0.tar.gz
打开:cd perl-5.28.0
①命令:./Configure -des -Dprefix=/usr/perl5
②命令:make
③命令:make test
④命令:make install
⑤命令:ln -s /usr/perl5/bin/perl /usr/bin/perl
查看版本验证是否安装成功:perl -v
openssl官网下载地址
将openssl下载到home目录下
命令下载:
wget -O /home/OpenSSL_1_1_1.tar.gz https://github.com/openssl/openssl/archive/OpenSSL_1_1_1.tar.gz
解压OpenSSL
命令:tar -zxvf OpenSSL_1_1_1.tar.gz
openssl安装帮助文档地址
If you want to just get on with it, do:
on Unix (again, this includes Mac OS/X):
$ ./config
$ make
$ make test
$ make install
到文件解压目录下命令:cd openssl-OpenSSL_1_1_1/
①命令: ./config shared zlib --prefix=/usr/openssl
②命令:make
③命令:make install
重命名原来的openssl命令
mv /usr/bin/openssl /usr/bin/openssl.backup
重命名原来的openssl头文件目录
mv /usr/include/openssl /usr/include/openssl.backup
将安装好的openssl 的openssl命令软连到/usr/bin/openssl
ln -s /usr/openssl/bin/openssl /usr/bin/openssl
将安装好的openssl 的openssl目录软连到/usr/include/openssl
ln -s /usr/openssl/include/openssl /usr/include/openssl
将安装好的openssl 的openssl库文件连到/usr/lib64/目录下
ln -s /usr/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
查看版本验证是否安装成功:openssl version
命令下载:
wget -O /home/libressl-2.8.2.tar.gz https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.8.2.tar.gz
解压libressl-2.8.2.tar.gz
命令:tar -zxvf libressl-2.8.2.tar.gz
打开解压目录:cd libressl-2.8.2/
安装帮助如下:
./configure # see ./configure --help for configuration options
make check # runs builtin unit tests
make install # set DESTDIR= to install to an alternate location
①命令: ./configure --prefix=/usr/libressl-2.8.2
②命令:make
③命令:make install
④命令:mv /usr/bin/openssl /usr/bin/openssl.backup
⑤命令:ln -s /usr/libressl-2.8.2/bin/openssl /usr/bin/openssl
⑥命令:openssl version
安装完成后我们来配置PKG_CONFIG_PATH环境变量来解决头文件和动态库无法找到的问题(也就是SSL模块无法找到的关键解决办法)
在默认情况下,每个支持 pkg-config 的库对应的.pc文件在安装后都位于安装目录中的lib/pkgconfig目录下,所以我们打开安装目录:
cd /usr/libressl-2.8.2/lib/pkgconfig
添加环境变量PKG_CONFIG_PATH的命令:
export PKG_CONFIG_PATH=/usr/libressl-2.8.2/lib/pkgconfig:$PKG_CONFIG_PATH
查看PKG_CONFIG_PATH环境变量是否添加了路径:
echo $PKG_CONFIG_PATH
打开下载目录:
cd /home/Python-3.7.1
命令:./configure --prefix=/usr/Python-3.7.1 --with-ssl-default-suites=openssl --enable-optimizations
命令:
make
命令:
make install
①打开安装目录下的bin目录
命令:
cd /usr/Python-3.7.1/bin
②查询PATH
命令:
echo $PATH
③用命令:pwd
,获取当前目录路径,方便第四步复制路径
[root@localhost bin]# pwd
/usr/Python-3.7.1/bin
④在环境变量追加路径
命令:
PATH=$PATH:/usr/Python-3.7.1/bin
查看命令:echo $PATH
①链接文件目录
ln -s /usr/Python-3.7.1/bin/python3 /usr/bin/python3
ln -s /usr/Python-3.7.1/bin/pip3 /usr/bin/pip3
②检测是否成功
输入命令:
python3
运行的是3.7.1的python
[root@localhost bin]# python3
Python 3.7.1 (default, Nov 10 2018, 09:39:53)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
③检测pip3是否能用了
输入命令: pip3 install ipython
pip升级命令:pip3 install --upgrade pip
openssl: error while loading shared libraries: libssl.so.1.1: cannot
open shared object file: No such file or directory
去到/usr/openssl/lib/目录下将libssl.so.1.1链接到系统lib文件夹下
ln -s /usr/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
pip is configured with locations that require TLS/SSL, however the ssl
module in Python is not available.
打开python下载的解压目录,重新编译文件看看缺少什么文件
打开下载的解压目录命令:
cd /home/Python-3.7.1
编译命令:make
以下就是缺少的模块,Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs,
无法生成 ssl 模块
python 需要一个 openssl 1.0.2 或1.1 兼容的 libssl 与 X509_VERIFY_PARAM_set1_host ()。
libressl 2.6.4 和更早版本不提供必要的 api,
(注意:这个下载libressl-2.8.2就可以解决X509_VERIFY_PARAM_set1_host(),往下拉下载)
The necessary bits to build these optional modules were not found:
_dbm _gdbm _lzma
_ssl _uuid
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc atexit pwd
time
Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381
请照下列方法按顺序安装!!
回到你的解压源码文件夹目录将安装的软件卸载,
命令是:make uninstall
。
卸载后在照着下面安装就可以了。
如果python3.7.1 make出错,请删除整个文件夹,重新解压!!
yum install -y zlib zlib-devel openssl-devel sqlite-devel bzip2-devel libffi libffi-devel gcc gcc-c++ ncurses-devel sqlite readline-devel tk tk-devel gdbm gdbm-devel db4-devel libpcap-devel lzma xz xz-devel libuuid-devel perl zlib* opensll*
rpm -qa | grep openssl
wget -O /home/OpenSSL_1_1_1.tar.gz https://github.com/openssl/openssl/archive/OpenSSL_1_1_1.tar.gz
cd /home
tar -zxvf OpenSSL_1_1_1.tar.gz
cd openssl-OpenSSL_1_1_1/
./config --prefix=$HOME/openssl shared zlib
make
make install
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/openssl/lib" >> $HOME/.bash_profile
source $HOME/.bash_profile
wget -O /home/Python-3.7.1.tgz https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
cd /home
tar -zxvf Python-3.7.1.tgz
cd /home/Python-3.7.1
./configure --prefix=$HOME/Python-3.7.1 --with-openssl=$HOME/openssl
make
make install
ln -s /root/Python-3.7.1/bin/python3 /usr/bin/python3
ln -s /root/Python-3.7.1/bin/pip3 /usr/bin/pip3
pip3 install --upgrade pip
pip3 install ipython