Skip to content

Email: admin@alshowto.com

Al's Down`N Dirty KB

Al's Down`N Dirty KB

Get`Er Done

  • Home
  • Web
  • Specific PHP in Apache

Specific PHP in Apache

Posted on January 23, 2023January 23, 2023 By admin No Comments on Specific PHP in Apache
Linux, Web

Hello all, this came in handy the other day for nextcloud so I figured I would put a quick post about it out. Let’s say, you want a PHP 8.0 to be used in Apache. Here is what I did to do that specific option. Also, it is what I would recommend if you are using NextCloud.

Add Needed Repository

Below, it will setup the apt repository to get the latest available PHP version that are compatible with Debian.

sudo apt update

sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2

KEYRING=/etc/apt/trusted.gpg.d/sury-keyring.gpg

curl -fsSL  https://packages.sury.org/php/apt.gpg| sudo gpg --dearmor -o $KEYRING


echo "deb [signed-by="$KEYRING"] https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list

Update and Install Specific Version of PHP.

sudo apt update && sudo apt upgrade
Currently, Nextcloud only supports up to PHP 8.0 so if installing on NextCloud do not go over PHP 8.0 or it will fail to load. Nextcloud Hub II (23.0.12). Oh, there is a new version of nextcloud out at 24 so I will have to try that and update post as needed.

Next, Install PHP specific packages. Below, are the ones I used in NextCloud.

sudo apt install php-imagick php8.0-fpm php8.0-common php8.0-gd php8.0-imap php8.0-mysql php8.0-curl php8.0-zip php8.0-xml php8.0-mbstring php8.0-bz2 php8.0-intl php8.0-gmp php8.0-redis php8.0-imagick php8.0-gmp php8.0-bcmath

Configure Apache

Below configures Apache to use 8.0 fpm. As shown, I was using 8.1 so adjust according to needs to disable modules of the specific PHP that is not wanted and enable modules for correct versions as needed.
sudo a2dismod php8.1
sudo a2dismod mpm_prefork
sudo a2disconf php8.1-fpm
sudo a2enmod mpm_event
# optional in case its enabled
sudo a2enmod proxy
# optional in case its enabled
sudo a2enmod proxy_fcgi
sudo a2enconf php8.0-fpm
sudo systemctl restart php8.0-fpm
sudo systemctl restart apache2
# manually set php version for CLI
sudo update-alternatives --set php /usr/bin/php8.0
sudo update-alternatives --set phar /usr/bin/phar8.0
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.0

sudo systemctl status php8.0-fpm
sudo systemctl stop php8.1-fpm
sudo systemctl mask php8.1-fpm

Related

Tags: Apache Debian11 Nextcloud PHP

Post navigation

❮ Previous Post: ATTiny 1626 Timers
Next Post: Get PlatformIO and serialupdi Working ❯

You may also like

Linux
Configure SSH for Different Port
October 17, 2022
Let's Encrypt
Proxmox Manual Update Certs
October 20, 2022
Proxmox and HAProxy
Linux
Proxmox VM Custer Behind HAProxy Load Balancer
October 14, 2022
Linux
pfSense and Qemu Guest Agent
October 26, 2022

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 Al's Down`N Dirty KB.

Theme: Oceanly Premium by ScriptsTown