Ga naar inhoud

PHP 8.2

In deze handleiding leer je hoe je PHP 8.2 installeert, modules toevoegt, en het gebruikt met Apache2 of Nginx (PHP‑FPM) op Debian/Ubuntu.

Wat is PHP?

  • PHP is een populaire scripttaal voor webapplicaties.
  • Versie 8.2 brengt prestatieverbeteringen en nieuwe features.

1. Installatie van PHP 8.2

sudo apt update
sudo apt install -y php8.2
Voorbeeld output
The following NEW packages will be installed:
  php8.2

2. Installatie van PHP‑modules

sudo apt install -y php8.2-<module1> php8.2-<module2> 

Gebruik de tabel hieronder voor veelgebruikte en belangrijke modules (gegroepeerd per categorie):

Module Beschrijving
php8.2-mysql MySQL/MariaDB aansluiting via MySQL Native Driver
php8.2-pgsql PostgreSQL ondersteuning
php8.2-sqlite3 SQLite3 ondersteuning
php8.2-odbc ODBC-database koppelingen
php8.2-pdo-mysql PDO driver voor MySQL
php8.2-pdo-pgsql PDO driver voor PostgreSQL
php8.2-pdo-sqlite PDO driver voor SQLite
Module Beschrijving
php8.2-mbstring Multibyte tekstverwerking (UTF-8)
php8.2-intl Internationalisatie (datums, talen, formats)
php8.2-iconv Conversie tussen verschillende tekstencoderingen
Module Beschrijving
php8.2-curl HTTP-verzoeken en API-communicatie
php8.2-zip ZIP-bestanden lezen/schrijven
php8.2-soap SOAP-protocol ondersteuning
php8.2-ftp FTP-client functionaliteit
Module Beschrijving
php8.2-gd Afbeeldingsverwerking (resizing, thumbnails)
php8.2-imagick Beeldverwerking via ImageMagick
php8.2-exif EXIF metadata uitlezen in afbeeldingen
Module Beschrijving
php8.2-bcmath Nauwkeurige wiskundige berekeningen
php8.2-opcache Bytecode caching voor performance
php8.2-common Gemeenschappelijke PHP-functies/enablers
php8.2-cli PHP via de command line interface
php8.2-fpm FastCGI Process Manager voor webserver-integratie
php8.2-readline Interactieve shellfunctionaliteit
php8.2-json JSON-parsing en -serialisatie
php8.2-xml XML-parsing ondersteuning
php8.2-dom Werken met XML-document object model (DOM)
php8.2-filter Geavanceerde filteringfunctionaliteit
php8.2-tokenizer Tokenisatie voor PHP-code
php8.2-ctype Teksttype herkenning functies
php8.2-fileinfo Bestandstype-identificatie (MIME types)
php8.2-shmop Shared memory segment beheer
php8.2-sockets Socket-communicatie ondersteuning
php8.2-sodium Modern cryptografie (libsodium)
php8.2-ldap LDAP directory ondersteuning
Module Beschrijving
php8.2-apcu Application-level caching
php8.2-memcached Memcached caching support
php8.2-redis Redis caching en datastore ondersteuning
Module Beschrijving
php8.2-dev Headers en scripts nodig voor extensieontwikkeling
php8.2-xdebug Debugging en profiler ondersteuning
php8.2-pcov Code coverage tijdens testen

3. PHP integreren met webservers

Apache2 (mod_php)

sudo apt install -y libapache2-mod-php8.2
sudo systemctl restart apache2

Nginx (via PHP‑FPM)

sudo apt install -y php8.2-fpm
sudo systemctl enable --now php8.2-fpm

Controleer de status:

systemctl status php8.2-fpm

4. PHP‑versie en modules controleren

php -v
php -m

Voorbeeld output:

PHP 8.2.10 (cli) ...
[PHP Modules]
bcmath
bz2
...

5. Configuratiebestanden

  • /etc/php/8.2/apache2/php.ini
  • /etc/php/8.2/fpm/php.ini
  • /etc/php/8.2/cli/php.ini

Aanpassingen zoals memory_limit, upload_max_filesize, post_max_size kun je hier doen.

Herstart services:

sudo systemctl restart apache2         # bij Apache
sudo systemctl restart php8.2-fpm nginx  # bij Nginx & PHP‑FPM

6. Test-pagina maken

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
# Bezoek http://SERVER-IP/info.php in je browser
sudo rm /var/www/html/info.php

7. Verwijderen van PHP 8.2 en modules

sudo apt purge -y php8.2*
sudo apt autoremove -y

Conclusie

Je hebt nu een complete PHP 8.2-installatie met uitgebreide modulekeuze, klaar voor gebruik met Apache of Nginx.

✅ Klaar om PHP‑applicaties te draaien in een professionele setup!