Install Multiple Versions of PHP and OpenSSL on Linux Fedora v44 Workstation

In this subject, we are going to learn and practice by installing PHP multiple versions (v5.6.40, v7.0.33, v7.1.33, v7.2.34, v7.3.33, v.7.4.30, v8.0.30, v8.1.34, v8.2.32, v8.3.32, v8.4.24, v8.5.9) on Linux Fedora v44 Workstation x64.

 

Download PHP source from https://museum.php.net

then save them into ~/Downloads

-----     -----     -----     -----     -----

PRE-REQUISITES

$ sudo dnf install -y gcc gcc-c++ make readline-devel zlib-devel flex bison libxml2-devel libxslt-devel openssl-devel perl-devel python3-devel

$ sudo dnf install -y @development-tools @c-development

$ sudo dnf install -y libxml2-devel openssl-devel sqlite-devel zlib-devel libcurl-devel

$ sudo dnf install -y libpq-devel

$ sudo dnf install -y perl-FindBin perl-IPC-Cmd gcc make perl-interpreter

$ sudo dnf install -y perl-Time-Piece

$ sudo dnf install -y oniguruma-devel

$ sudo dnf install -y aspell-devel

$ sudo dnf install -y libtidy-devel

$ sudo dnf install -y libedit-devel

$ sudo dnf install -y libzip-devel

$ sudo dnf install -y gmp-devel

$ sudo dnf install -y net-snmp-devel

$ sudo dnf install -y libsodium-devel 

-----     -----     -----     -----     -----

Fedora 44 Workstation ships natively with OpenSSL 3.x. Because OpenSSL 3.x introduced major API changes, PHP versions earlier than PHP 8.1 cannot be compiled directly against Fedora's system OpenSSL library.

For older PHP versions, you must compile and install isolated legacy versions of OpenSSL into custom locations (such as /opt/openssl-1.0.2 or /opt/openssl-1.1.1), similar to the procedure shown in your installation steps.

OpenSSL Compatibility Matrix

PHP VersionOfficial OpenSSL RequirementRecommended OpenSSL Version (Fedora 44)Works with Native Fedora OpenSSL 3.x?
PHP 5.6.40>= 0.9.8, < 1.1.0

OpenSSL 1.0.2u

No (Requires /opt/openssl-1.0.2)

PHP 7.0.33>= 0.9.8, < 1.2.0OpenSSL 1.0.2uNo (Requires /opt/openssl-1.0.2)
PHP 7.1.33>= 1.0.1, < 3.0OpenSSL 1.0.2u or 1.1.1wNo (Requires /opt/openssl-1.0.2 or /opt/openssl-1.1.1)
PHP 7.2.34>= 1.0.1, < 3.0OpenSSL 1.1.1wNo (Requires /opt/openssl-1.1.1)
PHP 7.3.33>= 1.0.1, < 3.0OpenSSL 1.1.1wNo (Requires /opt/openssl-1.1.1)
PHP 7.4.30>= 1.0.1, < 3.0OpenSSL 1.1.1wNo (Requires /opt/openssl-1.1.1)
PHP 8.0.30>= 1.0.1, < 3.0OpenSSL 1.1.1wNo (Requires /opt/openssl-1.1.1)
PHP 8.1.34>= 1.0.2, < 4.0OpenSSL 3.x (or 1.1.1w)Yes (Native system OpenSSL)
PHP 8.2.32>= 1.0.2, < 4.0OpenSSL 3.xYes (Native system OpenSSL)
PHP 8.3.32>= 1.0.2, < 4.0OpenSSL 3.xYes (Native system OpenSSL)
PHP 8.4.24>= 1.1.1, < 4.0OpenSSL 3.xYes (Native system OpenSSL)
PHP 8.5.9>= 1.1.1, < 4.0OpenSSL 3.x / 3.5Yes (Native system OpenSSL)

Implementation Summary 

  • PHP 5.6.40 – PHP 7.0.33: Must be compiled against OpenSSL 1.0.2u built manually into a custom prefix like --prefix=/opt/openssl-1.0.2.
  • PHP 7.1.33 – PHP 8.0.30: Best compiled against OpenSSL 1.1.1w built into a separate prefix like --prefix=/opt/openssl-1.1.1.
  • PHP 8.1.34 – PHP 8.5.9: Can be compiled directly using Fedora 44's system OpenSSL development files (openssl-devel) using --with-openssl without needing custom source builds.

 

Download OpenSSL source from https://openssl-library.org/source/old/index.html

then save them into ~/Downloads 

 

Install OpenSSL v1.0.2u for PHP v5.6.40 , v7.0.33

$ cd ~/Downloads

$ wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz && clear && ls -al | grep "openssl"

$ cd /opt

$ tar -xf openssl-1.0.2u.tar.gz

$ sudo mv openssl-1.0.2u openssl-1.0.2-src 

$ cd openssl-1.0.2-src

$ sudo make clean 2>/dev/null || true  

$ sudo ./config --prefix=/opt/openssl-1.0.2 --openssldir=/opt/openssl-1.0.2 shared

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

 

Install OpenSSL v1.1.1w for PHP v7.1.33 , v7.2.34 , v7.3.33 , v7.4.30 , v8.0.30

$ cd ~/Downloads

$ wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz && clear && ls -al | grep "openssl"

$ cd /opt

$ tar -xf openssl-1.1.1w.tar.gz

$ sudo mv openssl-1.1.1w openssl-1.1.1-src

$ cd openssl-1.1.1-src

$ sudo make clean 2>/dev/null || true

$ sudo ./config --prefix=/opt/openssl-1.1.1 --openssldir=/opt/openssl-1.1.1 shared

$ sudo make clean 

$ sudo make -j$(nproc)

$ sudo make install 

 

Install OpenSSL v3.5 LTS for PHP v8.1.34, v8.2.32, v8.3.32, v8.4.24, v8.5.9

$ cd ~/Downloads

$ wget https://www.openssl.org/source/old/3.5/openssl-3.5.7.tar.gz && clear && ls -al | grep "openssl"

$ cd /opt

$ tar -xf openssl-3.5.7.tar.gz

$ sudo mv openssl-3.5.7 openssl-3.5.7-src

$ cd openssl-3.5.7-src

$ sudo make clean 2>/dev/null || true

$ sudo ./config --prefix=/opt/openssl-3.5.7 --openssldir=/opt/openssl-3.5.7 shared

$ sudo make clean 

$ sudo make -j$(nproc)

$ sudo make install 

-----     -----     -----     -----     -----

PHP v5.6.40   -   customize port 9056

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-5.6.40.tar.gz .

$ sudo tar -xf ./php-5.6.40.tar.gz

$ sudo rm -rf ./php-5.6.40.tar.gz

$ sudo mv php-5.6.40 php-5.6

$ cd php-5.6 

$ sudo CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure   --prefix=/opt/php/php-5.6   --with-openssl=/opt/openssl-1.0.2   --with-zlib   --enable-mbstring   --enable-sockets   --enable-fpm   --with-curl   --with-pdo-mysql   --with-pdo-pgsql   --with-gd 

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9056"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v5.6.40 FPM

$ sudo touch /opt/php/php-5.6/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-5.6.service

$ sudo nano /etc/systemd/system/php-5.6.service

Paste these :

[Unit]
Description=PHP 5.6 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-5.6/var/run/php-fpm.pid
ExecStart=/opt/php/php-5.6/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-5.6/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-5.6.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-5.6.service

 

Check is php-5.6.service run : 

$ sudo systemctl status php-5.6.service

 

Check is port 9056 of php-5.6.service run :

$ sudo netstat -tulpn | grep 9056 

-----     -----     -----     -----     ----- 

PHP v7.0.33   -   customize port 9070

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-7.0.33.tar.gz .

$ sudo tar -xf ./php-7.0.33.tar.gz

$ sudo rm -rf ./php-7.0.33.tar.gz

$ sudo mv php-7.0.33 php-7.0

$ cd php-7.0

$ sudo CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure   --prefix=/opt/php/php-7.0   --with-openssl=/opt/openssl-1.0.2   --with-zlib   --enable-mbstring   --enable-sockets   --enable-fpm   --with-curl   --with-pdo-mysql   --with-pdo-pgsql   --with-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9070"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v7.0.33 FPM

$ sudo touch /opt/php/php-7.0/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-7.0.service

$ sudo nano /etc/systemd/system/php-7.0.service

Paste these :

[Unit]
Description=PHP 7.0 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-7.0/var/run/php-fpm.pid
ExecStart=/opt/php/php-7.0/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-7.0/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-7.0.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-7.0.service

 

Check is php-7.0.service run : 

$ sudo systemctl status php-7.0.service

 

Check is port 9070 of php-7.0.service run :

$ sudo netstat -tulpn | grep 9070

-----     -----     -----     -----     ----- 

PHP v7.1.33   -   customize port 9071

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-7.1.33.tar.gz .

$ sudo tar -xf ./php-7.1.33.tar.gz

$ sudo rm -rf ./php-7.1.33.tar.gz

$ sudo mv php-7.1.33 php-7.1

$ cd php-7.1

$ sudo CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure   --prefix=/opt/php/php-7.1   --with-openssl=/opt/openssl-1.0.2   --with-zlib   --enable-mbstring   --enable-sockets   --enable-fpm   --with-curl   --with-pdo-mysql   --with-pdo-pgsql   --with-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9071"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v7.1.33 FPM

$ sudo touch /opt/php/php-7.1/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-7.1.service

$ sudo nano /etc/systemd/system/php-7.1.service

Paste these :

[Unit]
Description=PHP 7.1 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-7.1/var/run/php-fpm.pid
ExecStart=/opt/php/php-7.1/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-7.1/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-7.1.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-7.1.service

 

Check is php-7.1.service run : 

$ sudo systemctl status php-7.1.service

 

Check is port 9071 of php-7.1.service run :

$ sudo netstat -tulpn | grep 9071

-----     -----     -----     -----     ----- 

PHP v7.2.34   -   customize port 9072

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-7.2.34.tar.gz .

$ sudo tar -xf ./php-7.2.34.tar.gz

$ sudo rm -rf ./php-7.2.34.tar.gz

$ sudo mv php-7.2.34 php-7.2

$ cd php-7.2

$ sudo CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure   --prefix=/opt/php/php-7.2   --with-openssl=/opt/openssl-1.1.1   --with-zlib   --enable-mbstring   --enable-sockets   --enable-fpm   --with-curl   --with-pdo-mysql   --with-pdo-pgsql   --with-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9072"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v7.2.34 FPM

$ sudo touch /opt/php/php-7.2/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-7.2.service

$ sudo nano /etc/systemd/system/php-7.2.service

Paste these :

[Unit]
Description=PHP 7.2 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-7.2/var/run/php-fpm.pid
ExecStart=/opt/php/php-7.2/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-7.2/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-7.2.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-7.2.service

 

Check is php-7.2.service run : 

$ sudo systemctl status php-7.2.service

 

Check is port 9072 of php-7.2.service run :

$ sudo netstat -tulpn | grep 9072

-----     -----     -----     -----     ----- 

PHP v7.3.33   -   customize port 9073

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-7.3.33.tar.gz .

$ sudo tar -xf ./php-7.3.33.tar.gz

$ sudo rm -rf ./php-7.3.33.tar.gz

$ sudo mv php-7.3.33 php-7.3

$ cd php-7.3

$ sudo CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure   --prefix=/opt/php/php-7.3   --with-openssl=/opt/openssl-1.1.1   --with-zlib   --enable-mbstring   --enable-sockets   --enable-fpm   --with-curl   --with-pdo-mysql   --with-pdo-pgsql   --with-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9073"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v7.3.33 FPM

$ sudo touch /opt/php/php-7.3/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-7.3.service

$ sudo nano /etc/systemd/system/php-7.3.service

Paste these :

[Unit]
Description=PHP 7.3 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-7.3/var/run/php-fpm.pid
ExecStart=/opt/php/php-7.3/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-7.3/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-7.3.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-7.3.service

 

Check is php-7.3.service run : 

$ sudo systemctl status php-7.3.service

 

Check is port 9073 of php-7.3.service run :

$ sudo netstat -tulpn | grep 9073

-----     -----     -----     -----     ----- 

PHP v7.4.30   -   customize port 9074

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-7.4.30.tar.gz .

$ sudo tar -xf ./php-7.4.30.tar.gz

$ sudo rm -rf ./php-7.4.30.tar.gz

$ sudo mv php-7.4.30 php-7.4

$ cd php-7.4

$ sudo CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure   --prefix=/opt/php/php-7.4   --with-openssl=/opt/openssl-1.1.1   --with-zlib   --enable-mbstring   --enable-sockets   --enable-fpm   --with-curl   --with-pdo-mysql   --with-pdo-pgsql   --with-gd 

$ sudo CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure   --prefix=/opt/php/php-7.4   --with-openssl=/opt/openssl-1.1.1   --with-zlib   --enable-mbstring   --enable-sockets   --enable-fpm   --with-curl   --with-pdo-mysql   --with-pdo-pgsql   --enable-gd

$ sudo PKG_CONFIG_PATH="/opt/openssl-1.1.1/lib/pkgconfig:$PKG_CONFIG_PATH" CPPFLAGS="-I/opt/openssl-1.1.1/include" LDFLAGS="-L/opt/openssl-1.1.1/lib -Wl,-rpath,/opt/openssl-1.1.1/lib" CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure --prefix=/opt/php/php-7.4 --with-openssl=/opt/openssl-1.1.1 --with-zlib --enable-mbstring --enable-sockets --enable-fpm --with-curl --with-pdo-mysql --with-pdo-pgsql --enable-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9074"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v7.3.33 FPM

$ sudo touch /opt/php/php-7.4/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-7.4.service

$ sudo nano /etc/systemd/system/php-7.4.service

Paste these :

[Unit]
Description=PHP 7.4 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-7.4/var/run/php-fpm.pid
ExecStart=/opt/php/php-7.4/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-7.4/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-7.4.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-7.4.service

 

Check is php-7.4.service run : 

$ sudo systemctl status php-7.4.service

 

Check is port 9074 of php-7.4.service run :

$ sudo netstat -tulpn | grep 9074

-----     -----     -----     -----     ----- 

PHP v8.0.30   -   customize port 9080

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-8.0.30.tar.gz .

$ sudo tar -xf ./php-8.0.30.tar.gz

$ sudo rm -rf ./php-8.0.30.tar.gz

$ sudo mv php-8.0.30 php-8.0

$ cd php-8.0

$ sudo PKG_CONFIG_PATH="/opt/openssl-1.1.1/lib/pkgconfig:$PKG_CONFIG_PATH" CPPFLAGS="-I/opt/openssl-1.1.1/include" LDFLAGS="-L/opt/openssl-1.1.1/lib -Wl,-rpath,/opt/openssl-1.1.1/lib" CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure --prefix=/opt/php/php-8.0 --with-openssl=/opt/openssl-1.1.1 --with-zlib --enable-mbstring --enable-sockets --enable-fpm --with-curl --with-pdo-mysql --with-pdo-pgsql --enable-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9080"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v8.0.30 FPM

$ sudo touch /opt/php/php-8.0/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-8.0.service

$ sudo nano /etc/systemd/system/php-8.0.service

Paste these :

[Unit]
Description=PHP 8.0 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-8.0/var/run/php-fpm.pid
ExecStart=/opt/php/php-8.0/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-8.0/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-8.0.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-8.0.service

 

Check is php-8.0.service run : 

$ sudo systemctl status php-8.0.service

 

Check is port 9080 of php-8.0.service run :

$ sudo netstat -tulpn | grep 9080

-----     -----     -----     -----     ----- 

PHP v8.1.34   -   customize port 9081

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-8.1.34.tar.gz .

$ sudo tar -xf ./php-8.1.34.tar.gz

$ sudo rm -rf ./php-8.1.34.tar.gz

$ sudo mv php-8.1.34 php-8.1

$ cd php-8.1

$ sudo PKG_CONFIG_PATH="/opt/openssl-3.5.7/lib/pkgconfig:$PKG_CONFIG_PATH" CPPFLAGS="-I/opt/openssl-3.5.7/include" LDFLAGS="-L/opt/openssl-3.5.7/lib -Wl,-rpath,/opt/openssl-3.5.7/lib" CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure --prefix=/opt/php/php-8.1 --with-openssl=/opt/openssl-3.5.7 --with-zlib --enable-mbstring --enable-sockets --enable-fpm --with-curl --with-pdo-mysql --with-pdo-pgsql --enable-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9081"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v8.1.34 FPM

$ sudo touch /opt/php/php-8.1/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-8.1.service

$ sudo nano /etc/systemd/system/php-8.1.service

Paste these :

[Unit]
Description=PHP 8.1 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-8.1/var/run/php-fpm.pid
ExecStart=/opt/php/php-8.1/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-8.1/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-8.1.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-8.1.service

 

Check is php-8.1.service run : 

$ sudo systemctl status php-8.1.service

 

Check is port 9081 of php-8.1.service run :

$ sudo netstat -tulpn | grep 9081

-----     -----     -----     -----     ----- 

PHP v8.2.32   -   customize port 9082

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-8.2.32.tar.gz .

$ sudo tar -xf ./php-8.2.32.tar.gz

$ sudo rm -rf ./php-8.2.32.tar.gz

$ sudo mv php-8.2.32 php-8.2

$ cd php-8.2

$ sudo PKG_CONFIG_PATH="/opt/openssl-3.5.7/lib/pkgconfig:$PKG_CONFIG_PATH" CPPFLAGS="-I/opt/openssl-3.5.7/include" LDFLAGS="-L/opt/openssl-3.5.7/lib -Wl,-rpath,/opt/openssl-3.5.7/lib" CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure --prefix=/opt/php/php-8.2 --with-openssl=/opt/openssl-3.5.7 --with-zlib --enable-mbstring --enable-sockets --enable-fpm --with-curl --with-pdo-mysql --with-pdo-pgsql --enable-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9082"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v8.2.32 FPM

$ sudo touch /opt/php/php-8.2/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-8.2.service

$ sudo nano /etc/systemd/system/php-8.2.service

Paste these :

[Unit]
Description=PHP 8.2 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-8.2/var/run/php-fpm.pid
ExecStart=/opt/php/php-8.2/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-8.2/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-8.2.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-8.2.service

 

Check is php-8.2.service run : 

$ sudo systemctl status php-8.2.service

 

Check is port 9082 of php-8.2.service run :

$ sudo netstat -tulpn | grep 9082

-----     -----     -----     -----     ----- 

PHP v8.3.32   -   customize port 9083

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-8.3.32.tar.gz .

$ sudo tar -xf ./php-8.3.32.tar.gz

$ sudo rm -rf ./php-8.3.32.tar.gz

$ sudo mv php-8.3.32 php-8.3

$ cd php-8.3

$ sudo PKG_CONFIG_PATH="/opt/openssl-3.5.7/lib/pkgconfig:$PKG_CONFIG_PATH" CPPFLAGS="-I/opt/openssl-3.5.7/include" LDFLAGS="-L/opt/openssl-3.5.7/lib -Wl,-rpath,/opt/openssl-3.5.7/lib" CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure --prefix=/opt/php/php-8.3 --with-openssl=/opt/openssl-3.5.7 --with-zlib --enable-mbstring --enable-sockets --enable-fpm --with-curl --with-pdo-mysql --with-pdo-pgsql --enable-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9083"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v8.3.32 FPM

$ sudo touch /opt/php/php-8.3/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-8.3.service

$ sudo nano /etc/systemd/system/php-8.3.service

Paste these :

[Unit]
Description=PHP 8.3 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-8.3/var/run/php-fpm.pid
ExecStart=/opt/php/php-8.3/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-8.3/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-8.3.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-8.3.service

 

Check is php-8.3.service run : 

$ sudo systemctl status php-8.3.service

 

Check is port 9083 of php-8.3.service run :

$ sudo netstat -tulpn | grep 9083

-----     -----     -----     -----     ----- 

PHP v8.4.24   -   customize port 9084

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-8.4.24.tar.gz .

$ sudo tar -xf ./php-8.4.24.tar.gz

$ sudo rm -rf ./php-8.4.24.tar.gz

$ sudo mv php-8.4.24 php-8.4

$ cd php-8.4

$ sudo PKG_CONFIG_PATH="/opt/openssl-3.5.7/lib/pkgconfig:$PKG_CONFIG_PATH" CPPFLAGS="-I/opt/openssl-3.5.7/include" LDFLAGS="-L/opt/openssl-3.5.7/lib -Wl,-rpath,/opt/openssl-3.5.7/lib" CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure --prefix=/opt/php/php-8.4 --with-openssl=/opt/openssl-3.5.7 --with-zlib --enable-mbstring --enable-sockets --enable-fpm --with-curl --with-pdo-mysql --with-pdo-pgsql --enable-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9084"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v8.4.24 FPM

$ sudo touch /opt/php/php-8.4/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-8.4.service

$ sudo nano /etc/systemd/system/php-8.4.service

Paste these :

[Unit]
Description=PHP 8.4 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-8.4/var/run/php-fpm.pid
ExecStart=/opt/php/php-8.4/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-8.4/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-8.4.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-8.4.service

 

Check is php-8.4.service run : 

$ sudo systemctl status php-8.4.service

 

Check is port 9084 of php-8.4.service run :

$ sudo netstat -tulpn | grep 9084

-----     -----     -----     -----     ----- 

PHP v8.5.9   -   customize port 9085

$ sudo mkdir -p /opt/php

$ cd /opt/php

$ sudo cp ~/Downloads/php-8.5.9.tar.gz .

$ sudo tar -xf ./php-8.5.9.tar.gz

$ sudo rm -rf ./php-8.5.9.tar.gz

$ sudo mv php-8.5.9 php-8.5

$ cd php-8.5

$ sudo PKG_CONFIG_PATH="/opt/openssl-3.5.7/lib/pkgconfig:$PKG_CONFIG_PATH" CPPFLAGS="-I/opt/openssl-3.5.7/include" LDFLAGS="-L/opt/openssl-3.5.7/lib -Wl,-rpath,/opt/openssl-3.5.7/lib" CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure --prefix=/opt/php/php-8.5 --with-openssl=/opt/openssl-3.5.7 --with-zlib --enable-mbstring --enable-sockets --enable-fpm --with-curl --with-pdo-mysql --with-pdo-pgsql --enable-gd

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

$ sudo cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf 

$ sudo cp php.ini-production lib/php.ini

$ sudo nano etc/php-fpm.d/www.conf

Find in nano "127.0.0.1:9000" then change to "127.0.0.1:9085"

Save php-fpm.conf by press Ctrl + x

Now, we were gonna create linux service for PHP v8.5.9 FPM

$ sudo touch /opt/php/php-8.5/var/run/php-fpm.pid

$ sudo touch /etc/systemd/system/php-8.5.service

$ sudo nano /etc/systemd/system/php-8.5.service

Paste these :

[Unit]
Description=PHP 8.5 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php/php-8.5/var/run/php-fpm.pid
ExecStart=/opt/php/php-8.5/sbin/php-fpm --nodaemonize --fpm-config /opt/php/php-8.5/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

Then save php-8.5.service by press Ctrl + x

 

Reload linux services : 

$ sudo systemctl daemon-reload

 

Run service : 

$ sudo systemctl start php-8.5.service

 

Check is php-8.5.service run : 

$ sudo systemctl status php-8.5.service

 

Check is port 9085 of php-8.5.service run :

$ sudo netstat -tulpn | grep 9085

-----     -----     -----     -----     -----  

Enable PHP Extensions

For example, I will enable pgsql extension in php-7.4

$ cd /opt/php/php-7.4/ext/pgsql

$ cat /opt/php/php-7.4/lib/php.ini | grep ";extension="

Check first :

$ /opt/php/php-7.4/bin/php -m | grep pgsql

$ sudo make clean

$ sudo /opt/php/php-7.4/bin/phpize --clean

$ sudo /opt/php/php-7.4/bin/phpize

$ sudo CFLAGS="-g -O2 -std=gnu17 -fpermissive -Wno-error -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration" ./configure --with-php-config=/opt/php/php-7.4/bin/php-config --with-pgsql

$ sudo make clean

$ sudo make -j$(nproc)

$ sudo make install

$ ls -al /opt/php/php-7.4/lib/php/extensions/no-debug-non-zts-20190902

$ sudo nano /opt/php/php-7.4/lib/php.ini

Change extension_dir to be :

extension_dir = "/opt/php/php-7.4/lib/php/extensions/no-debug-non-zts-20190902"

Uncomment extension=pgsql to be :

extension=pgsql.so

Verify :

$ /opt/php/php-7.4/bin/php -m | grep pgsql

$ sudo systemctl restart php-7.4.service

 

Good job ! 

Comments