I have an old Bitnami WordPress server on the Amazon Lightsail server. Bitnami does not support upgrading the PHP version. The recommended solution is to create a new bitnami WordPress instance and migrate the website to the new lightsail instance. Since this server had many websites configured, I do not want to migrate the websites to the new bitnami WordPress instance. Here is how I upgraded the PHP version on bitnami Debian 10 server from PHP 7.3 to PHP 8.1
What we do is install the PHP version provided by the OS. Then update php.ini to use the non-defult MySQL socket location used by the Bitnami server. Create a php-fpm pool that runs as the “daemon” user. After that, we update the Apache configuration to use the new PHP version.
First, enable PHP repository
apt -y install apt-transport-https lsb-release ca-certificates wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
Install PHP 8.1
apt update apt install -y php8.1-bcmath php8.1-cli php8.1-common php8.1-curl php8.1-gd php8.1-imap php8.1-intl php8.1-mbstring php8.1-mysql php8.1-readline php8.1-soap php8.1-xml php8.1-xmlrpc php8.1-zip php8.1-fpm
If you need a different version of PHP, change 8.1 with whatever version you need.
Edit php.ini file
vi /etc/php/8.1/fpm/php.ini
Find
[Pdo_mysql] ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. pdo_mysql.default_socket=
Replace with
[Pdo_mysql] ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. pdo_mysql.default_socket= "/opt/bitnami/mysql/tmp/mysql.sock"
Find
mysqli.default_socket =
Replace with
mysqli.default_socket = "/opt/bitnami/mysql/tmp/mysql.sock"
Create a php-fpm pool file
vi /etc/php/8.1/fpm/pool.d/wp.conf
add
[wordpress] listen=/opt/bitnami/php/var/run/ww2.sock user=daemon group=daemon listen.owner=daemon listen.group=daemon pm=dynamic pm.max_children=5 pm.start_servers=2 pm.min_spare_servers=1 pm.max_spare_servers=3 pm.max_requests=5000
This pool will listen on unix socket “/opt/bitnami/php/var/run/ww2.sock”.
Enable and restart PHP 8.1 fpm service
systemctl enable php8.1-fpm systemctl restart php8.1-fpm
Edit file
vi /opt/bitnami/apache2/conf/bitnami/php-fpm.conf
For some installations, file is located at
vi /opt/bitnami/apache2/conf/php-fpm-apache.conf
Inside you file find
SetHandler "proxy:fcgi://www-fpm"
Find
www.sock
Replace With
www2.sock
Restart Apache
sudo /opt/bitnami/ctlscript.sh restart apache
See Bitnami
Leave a Reply