Getting Started

Getting Started

Installation

PHP

Check installed modules

php -m
dpkg --get-selections | grep -i php

Install PHP

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.1
sudo apt install php8.1-bcmath php8.1-bz2 php8.1-curl php8.1-gd php8.1-imagick php8.1-intl php8.1-mbstring php8.1-mysql php8.1-opcache php8.1-readline php8.1-xml php8.1-zip

Update configuration

sudo vim /etc/php/8.1/apache2/php.ini

Developement:

max_execution_time = 30
memory_limit = 256M
max_input_time = -1
upload_max_filesize = 512M
error_reporting = E_ALL

Production:

max_execution_time = 60
max_input_time = 60
memory_limit = 256M
upload_max_filesize = 8M
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING
sudo vim /etc/php/8.1/apache2/conf.d/10-opcache.ini

Production

opcache.enable=1
opcache.enable_cli=1
opcache.fast_shutdown=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=6000
opcache.memory_consumption=128
opcache.validate_timestamps=0

Register with Apache2

sudo apt install libapache2-mod-php8.1
sudo a2enmod php8.1
sudo service apache2 restart

Set the PHP CLI version

sudo update-alternatives --config php