Installing WordFence-cli on RHEL/AlmaLinux

The WordFence-cli has the following requirements:

Python >= 3.8
The C library libpcre >= 8.38
Python packages:
packaging >= 21.0
requests >= 2.3


First we will need to install libffi-devel and pcre-devel before compiling python3.8

yum install pcre-devel libffi-devel ncurses-devel -y

As we’ll install Python from source, let’s install the packages required for Python installation.

sudo yum -y install epel-release
sudo yum -y update

Reboot after the upgrade

sudo reboot

After the reboot, install build dependencies

sudo yum -y groupinstall "Development Tools"
sudo yum -y install openssl-devel bzip2-devel libffi-devel xz-devel

Confirm gcc is available:

$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Step 2: Download latest Python 3.8 Archive

Now download the latest archive of Python 3.8 release.

VERSION=3.8.18
sudo yum -y install wget
wget https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tgz

Extract the package.

tar xvf Python-$VERSION.tgz

Change the created directory:

cd Python-$VERSION/

Step 3: Install Python 3.8 on CentOS 7 / CentOS 8

Setup installation by running the configure script.

./configure --enable-optimizations

Initiate compilation of Python 3.8 on CentOS 7.

sudo make altinstall

If this was successful, you should get a message like below:

.....
copying build/scripts-3.8/pydoc3.8 -> /usr/local/bin
copying build/scripts-3.8/idle3.8 -> /usr/local/bin
copying build/scripts-3.8/2to3-3.8 -> /usr/local/bin
changing mode of /usr/local/bin/pydoc3.8 to 755
changing mode of /usr/local/bin/idle3.8 to 755
changing mode of /usr/local/bin/2to3-3.8 to 755
rm /usr/local/lib/python3.8/lib-dynload/_sysconfigdata__linux_x86_64-linux-gnu.py
rm -r /usr/local/lib/python3.8/lib-dynload/__pycache__
/usr/bin/install -c -m 644 ./Misc/python.man \
	/usr/local/share/man/man1/python3.8.18
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--altinstall --upgrade" ;; \
		install|*) ensurepip="--altinstall" ;; \
	esac; \
	 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpy9yqf1bp
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
...

Step 4: Check Python 3.8 on CentOS 8 / CentOS 7.

Confirm that the installation of Python 3.8 on CentOS 8 / CentOS 7 was successful.

$ python3.8 --version
Python 3.8.18

Pip is also installed.

$ pip3.8 --version
pip 19.2.3 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)

Installing WordFence-cli

Now we are going to run:

python3.8 -m pip install wordfence

Try running: wordfence

If you encounter following error:

Run:

python3.8 -m pip install urllib3==1.26.6

Run: wordfence --version