Self Hosted MediaWiki

Upgrading PHP from 7.0 to 7.3

Stop the apache2 web server

systemctl stop apache2

(optional) see the currently installed version of PHP

php -v

(optional) get a list of the additional installed PHP modules

dpkg -l | grep php | tee packages.txt

(optional) See the list of installed PHP modules

nano packages.txt

Install the GNUGPG keys; next command installs 3 packages for maximum compatibility and reduces errors, also helps with updating other packages like Webmin

apt install gnupg gnupg1 gnupg2

Install the the gpg keyring for PHP 7.3

wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

add the PHP 7.3 packages to the repo for future updates

echo “deb Index of /php/ $(lsb_release -sc) main” | tee /etc/apt/sources.list.d/php7.3.list

update\refresh the available packages before install

apt update

Install PHP 7.3 and the CLI support tools

apt install php7.3 php7.3-common php7.3-cli

Pin PHP v 7.3 in the updates to prevent future updates from installing later versions, breaking things

update-alternatives --set php $(which php7.3)

Install the additional packages used by MediaWiki ( the command below is all one item)

apt install -y php7.3 libapache2-mod-php7.3 php7.3-bz2 php7.3-curl php7.3-gd php7.3-mbstring php7.3-mcrypt php7.3-mysql php7.3-xml php7.3-zip php7.3-curl php7.3-json php7.3-opcache php7.3-readline php7.3-xml php7.3-apc php7.3-imagick php7.3-int php7.3-fpm

Next two items were apache2 configuration changes after being prompted by the system after testing ( need to investigate but enable for now)

a2enconf php7.3-fpm
2enmod proxy_fcgi setenvif

(optional) see the installed version of PHP, should be 7.3.x

php -v

Uninstall and remove PHP 7.0 and related 7.0 items

apt purge php7.0 php7.0-common

Update the system one last time to make sure everything is the latest versions

apt update && apt upgrade -yy && apt autoremove -y

This should complete the PHP upgrade; a reboot is NOT required

The next step is the upgrade of the the MediWiki from 1.30 to 1.35.1

If the PHP upgrade went well, suggest taking another snapshot now

3 Likes