原创内容,转载请注明出处:https://www.myzhenai.com.cn/post/3895.html
因为我服务器上有一个脚本需要用python来运行,同时在安装酸*乳的时候却需要Python3才能进行安装,所以为了两者兼顾,我需要升级我的python,但是安装Python3后,我的脚本却显示缺少ssl模块,并不能正常运行,而这个ssl模块是依赖openssl的,所以我必须按照以下的流程来进行。
编译安装Perl5(openssl依赖)--〉编译安装openssl(ssl模块依赖)--〉编译安装python3
在编译之前先安装依赖包
yum -y install xz wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel zlib* libffi-devel zlib1g-dev
编译安装Perl5
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 install
编译安装Openssl
wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz tar -xzvf openssl-1.1.1l.tar.gz cd openssl-1.1.1l ./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl make && make install vi /etc/ld.so.conf 添加内容: /usr/local/openssl/lib ldconfig -v ## 设置openssl命令的软链接 mv /usr/bin/openssl /usr/bin/openssl-back ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl ## 验证是否安装成功 openssl version -a
编译安装Python3
yum -y groupinstall "Development tools" yum -y install xz wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel wget https://www.python.org/ftp/python/3.8.8/Python-3.8.8.tar.xz tar xvJf Python-3.8.8.tar.xz mkdir /usr/local/python3 cd Python-3.8.8 vi Modules/Setup #打开这个文件 SSL=/usr/local/openssl #将SSL=后边的路径改成你openssl的安装目录路径 _ssl _ssl.c \ #这行去除#注释 -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ #这行去除#注释 -L$(SSL)/lib -lssl -lcrypto #这行去除#注释 ./configure --prefix=/usr/local/python3 --enable-optimizations --with-ssl make && make install mv /usr/bin/python /usr/bin/python-back ln -s /usr/local/python3/bin/python3 /usr/bin/python ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 pip3 install requests /usr/local/python3/bin/python3.8 -m pip install --upgrade pip
CentOS7防火墙 开放端口配置
查看开放端口 firewall-cmd --list-ports firewall-cmd --list-all 开放端口设置 firewall-cmd --zone=public --add-port=3389/tcp --permanent firewall-cmd --zone=public --add-port=3389/udp --permanent 重启防火墙 firewall-cmd --reload 开机启动防火墙 systemctl enable firewalld
关闭SeLinux
vi /etc/selinux/config 将SELINUX=enforcing改为SELINUX=disabled 设置后需要重启才能生效
修改root密码与SSH端口
sudo passwd root 输入2次密码,密码不可见 vi /etc/ssh/sshd_config port:22 #将22改成你需要的端口 PermitRootLogin yes #将no改为yes PasswordAuthentication yes #将no改为yes UsePAM no #将yes改为no vi /etc/services #修改22/tcp和22/udp这两行,将22改成你上边修改的登陆端口
到这一步,这次的编译安装与服务器设置完成。
sicnature ---------------------------------------------------------------------
I P 地 址: 18.191.27.78
区 域 位 置: 美国俄亥俄
系 统 信 息:
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普 | 海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source https://myzhenai.com.cn/post/3895.html
3条评论
File “/usr/bin/yum”, line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
在使用yum的时候如果提示以上错误,请使用以下方法解决
vi /usr/bin/yum
把#!/usr/bin/python修改为#!/usr/bin/python2.7
updates | 2.9 kB 00:00:00
File “/usr/libexec/urlgrabber-ext-down”, line 28
except OSError, e:
^
SyntaxError: invalid syntax
File “/usr/libexec/urlgrabber-ext-down”, line 28
except OSError, e:
^
SyntaxError: invalid syntax
File “/usr/libexec/urlgrabber-ext-down”, line 28
except OSError, e:
^
SyntaxError: invalid syntax
File “/usr/libexec/urlgrabber-ext-down”, line 28
except OSError, e:
^
SyntaxError: invalid syntax
File “/usr/libexec/urlgrabber-ext-down”, line 28
except OSError, e:
^
SyntaxError: invalid syntax
如果出现以上错误,请参考以下方法解决
vi /usr/libexec/urlgrabber-ext-down
将 #! /usr/bin/python 改成 #! /usr/bin/python2.7
如果ssr-python安装出错,请执行以下命令
Installed /usr/local/python3/lib/python3.8/site-packages/shadowsocks-3.0.0-py3.8.egg
Processing dependencies for shadowsocks==3.0.0
Finished processing dependencies for shadowsocks==3.0.0
writing list of installed files to ‘/usr/local/shadowsocks_python.log’
/usr/local/python3/lib/python3.8/site-packages/shadowsocks-3.0.0-py3.8.egg/shadowsocks/common.py:221: SyntaxWarning: “is” with a literal. Did you mean “==”?
if addr is “”:
/usr/local/python3/lib/python3.8/site-packages/shadowsocks-3.0.0-py3.8.egg/shadowsocks/common.py:233: SyntaxWarning: “is” with a literal. Did you mean “==”?
if len(block) is 1:
/usr/local/python3/lib/python3.8/site-packages/shadowsocks-3.0.0-py3.8.egg/shadowsocks/common.py:235: SyntaxWarning: “is not” with a literal. Did you mean “!=”?
while (ip & 1) == 0 and ip is not 0:
[Error] Shadowsocks-Python install failed.
Please visit: https://teddysun.com/486.html and contact.
[root@ip-1 centos]# find / -name ssserver
/usr/local/python3/bin/ssserver
[root@ip-1 centos]# ln -s /usr/local/python3/bin/ssserver /usr/bin/ssserver