Install PHP 8.1 On Ubuntu 20.04 (Apache and Nginx)

REF: https://computingforgeeks.com/how-to-install-php-on-ubuntu-linux-system/

I already added Ondřej Surý PPA repository. So Just install php8.1

The apache module and cli for php8.1 is included

Check it on CLI Terminal

Then install the extensions.

Install XDebug

Check

PHP8.1 On Apache2
Disable the old PHP

Enable PHP8.1

Also need to run

Restart Apache server

Check on the browser

Should show like PHP Version 8.1.6

CHANGE THE PHP8.1 SETTING
MODIFY SOME INI FILES IN:
/etc/php/8.1/fpm/php.ini  –> PHP-FPM  AS MAIN
/etc/php/8.1/apache/php.ini  –>APACHE
/etc/php/8.1/cli/php.ini –> CLI

RESTART

FOR PHP FPM

TO USE PHP8.1 WITHOUT FPM, PLS STOP PHP8.1 FPM

ALSO DISABLE SOME FPM MODULES (mpm_event)

IF NEEDED

THEN ENABLE mpm_prefork

RELOAD

NOW IT’D BE RUNNING

USE NGINX and PHP8.1-FPM
STOP APACHE2

INSTALL NGINX

MODIFY THE DEFAULT CONF

THEN ADD ‘index.php’ SO THE PHP FILE WOULD BE EXECUTED NOT DOWNLOADED.
ALSO UNCOMMENT ‘include snippets/fastcgi-php.conf;’ AND ‘fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;’ AND ‘location ~ /\.ht{…}’

CHECK SETTING: sudo nginx -t
RELOAD NGINX

SOMETIMES IT’D NEED TO RESTART/LOGOFF THE COMPUTER!!!
CHECK ON

CONFIGURE PHPMYADMIN WITH NGINX
MODIFY /etc/nginx/sites-available/default

THEN ADD:

RELOAD NGINX
OPEN PHPMYADMIN: http://localhost/phpmyadmin

Leave a Reply

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