I. Installation of OpenSSL
1. Download the compressed package on the root directory
wget http://www.openssl.org/source/openssl-1.0.2j.tar.gz
2, under the folder decompression, get openssl-1.0.2j folder
Tar-xzf openssl-1.0.2j.tar.gz
3. Enter the extracted directory:
CD openssl-1.0.2j
4, set the OpenSSL installation, (--prefix) parameters for the installation of the directory, that is, the installed files will appear in this directory:
./config--prefix=/usr/local/openssl
5. Execution of Orders
./config-t
6. Execute make to compile OpenSSL
Make
Here if the following error occurs
MAKE[1]: Gcc:command not found
Surf the internet to find out I installed the CentOS7 in the GCC compiler
Ensure the system network is unblocked, execute command yum-y install GCC installation gcc
7. Installing OPENSSL:
Make install
8. View version
OpenSSL version
Second, install Python3.6.4 and solve SSL problem
1, the installation python3.6 may use the dependence
Yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc gcc-c++ openssl-devel
2, to the Python website to find the download path, download with wget
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
3 Unpacking the TGZ package
TAR-XF python-3.6.5.tgz
4 Entering the Python directory
cd/python-3.6.5/
5, compile, install
5.1 Hint that the SSL module could not be found
After the Python installation is complete, you are prompted not to find the SSL module:
Import # if we can ' t import it, let the error propagate Importerror:no module named _ssl
5.2 Recompile Python (minus the last 4 lines of comments)
# Modify the Setup file under the Modules folder under the Unzip folder Setup.distvim modules/setup.dist# The results are as follows: Remove the last 4 lines of comments, Get the following result # Socket Module Helper for socket (2)_socket socketmodule.c timemodule.c# Socket Module helper for SSL support; must comment out the "other" socket line above D possibly edit the SSL variable:ssl=/usr/local/-duse_ssl-i$ (SSL)/include-i$ (SSL)/include/ -l$ (SSL)/lib-lssl-lcrypto
5.3 Compiling the installation
#这里要先把目录切回到解压文件夹下
./configure--prefix=/usr/local/python3makemake Install
5.4 Test, ready for normal use
[[Email protected] ~]#pythonPython 3.6.4 (default, May 28 2018, 23:45:10) [GCC4.1.2 20080704 (Red Hat 4.1.2-54)] on Linux2type" Help","Copyright","credits" or "License" forMore information.>>>ImportSSL>>>
Note: If you want to keep the old version, you do not need to do 6.72
6. Rename the old version of Python dependency
Ll/usr/bin | /usr/bin/python/usr/bin/python2.7
7. Delete the old soft link and create a new soft link to the latest Python
rm-rf/usr/bin/-s/usr/local/bin/python3.6/usr/bin/-V
Use the Yum command to error file "/usr/bin/yum", line except Keyboardinterrupt, E:
The problem occurs because:
Yum package management is written using python2.x, and after upgrading python2.x to python3.1.3, the problem occurs due to Python version syntax compatibility
Workaround:
Modify the Yum configuration file to point the Python version to the previous old version
# Vi/usr/bin/yum # !/usr/bin/python2.7
Modify the Urlgrabber-ext-down file to change the Python version
# Vi/usr/libexec/urlgrabber-ext-down # !/usr/bin/python2.7
Adding environment variables
Vim ~/.bash_profile
Add the following parameter
Export Path=/usr/local/python/bin: $PATH
Save
SOURCE ~/.bash_profile
Execute the script as follows:
Vim install_python.sh
#!/bin/BashEcho "Installing related Components"Yum Install-Y Openssl-develbzip2-devel expat-devel gdbm-devel readline-devel sqlite-develGCC-c++GCCopenssl-develEcho "Download the installation package"wgetHttps//www.python.org/ftp/python/3.6.5/Python-3.6.5.tgzEcho "Unpacking the installation package"Tar-XF python-3.6.5. tgz-c/root/&& cd/root/python-3.6.5/Echo "Add SSL Support"Cat>>/root/python-3.6.5/modules/setup.dist <<"EOF"_socket Socketmodule.cssl=/usr/local/Ssl_ssl _ssl.c-duse_ssl-i$ (SSL)/include-i$ (SSL)/include/OpenSSL-l$ (SSL)/lib-lssl-lcryptoeofEcho "compiling and installing Python"./configure--prefix=/usr/local/python && Make&& Make InstallCD/RootEcho "To delete an installation package"RM-rf/root/python-3.6.5. tgz &&RM-rf/root/python-3.6.5Echo "Adding environment Variables"Echo "export Path=/usr/local/python/bin: $PATH">> ~/. Bash_profilesource~/. Bash_profileEcho "the installation is complete, please perform python3 to test"
Reference article: 53021686
http://blog.51cto.com/13160495/2093863
Https://www.cnblogs.com/mlgjb/p/7976561.html
"Python" CentOs7 Python3 installing OpenSSL and resolving SSL issues