In terms of operation and maintenance , There are many scripts used , Some scripts use shell Writing will be tiring , use python It will be easier , because python There is a powerful class library , It can handle all kinds of environments well .
Let's demonstrate linux Installation on system python The process of :
Here we can download it directly from the official website :( Maybe the speed of opening the official website is a little slow .)python Official website
choice linux System :
Download the new in the stable version :
# download python package
wget https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tgz
# It's not installed here wget The partners , Sure yum Install
yum install -y wget
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
# see python
python -V
Python 2.7.5
tar -zxf Python-3.10.5.tgz
cd Python-3.10.5
./configure --prefix=/usr/local/python3/
make && make install
#python
PATH=/usr/local/python3/bin:$PATH
# After the save , Refresh profile
source /etc/profile
Add the execution file to /usr/bin Under the table of contents , Make it work globally
Before adding ,/usr/bin It's in the catalog python2 Version of the execution file
# Here we will introduce the original python Change your name
mv /usr/bin/python /usr/bin/python.bak
# Then create a soft connection
ls -n /usr/local/python3/bin/python3 /usr/bin/python
ls -n /usr/local/python3/bin/pip3 /usr/bin/pip
python -V
# The following will show :
Python 3.10.5
because yum and firewall All depend on python, So change /usr/bin The executable files under will make them unavailable , You need to modify the configuration ;
vi /usr/bin/yum
# Take the first line "#!/usr/bin/python" Change it to "#!/usr/bin/python2.7" that will do
vi /usr/libexec/urlgrabber-ext-down
# Same thing here ,#!/usr/bin/python Change it to #!/usr/bin/python2.7
vi /usr/bin/firewall-cmd
# Take the first line "#!/usr/bin/python" Change it to "#!/usr/bin/python2.7"
vi /usr/sbin/firewalld
# Take the first line "#!/usr/bin/python" Change it to "#!/usr/bin/python2.7"