Install PHP 8.3 and config Apache in Ubuntu 22.04



This content originally appeared on DEV Community and was authored by Automata

Install PHP:

sudo apt install php8.3

Install PHP module of Apache:

apt install libapache2-mod-php

Config PHP Module of Apache

By default, the PHP module is automatically enabled, if for some reason it is not enabled, you should run:

a2enmod php8.3

To update the PHP module configuration you must modify the files /etc/apache2/mods-enabled/php8.3.conf and /etc/apache2/mods-enabled/php8.*.load. Then you must restart the apache server by running the following command:

systemctl restart apache2.service

Confirm Installation

php -v

Optional Packages

PHP-CLI

Run PHP scripts via the CLI

apt install php-cli

PHP-CGI

Execute PHP scripts without installing the Apache PHP module

sudo apt install php-cgi

PHP-MySQL

apt install php-mysql

PHP-PgSQL

apt install php-pgsql


This content originally appeared on DEV Community and was authored by Automata