Docs / Web Servers / How to Install PHP with Apache

How to Install PHP with Apache

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 66 views · 1 min read

Apache with mod_php or PHP-FPM can serve PHP applications.

Install PHP

apt install php libapache2-mod-php php-mysql php-curl php-xml php-mbstring php-zip -y

Verify

php -v
systemctl restart apache2

Test

echo "<?php phpinfo();" > /var/www/html/info.php

Visit http://YOUR_IP/info.php. Remove after testing:

rm /var/www/html/info.php

Common PHP Extensions

apt install php-gd php-intl php-bcmath php-soap php-ldap -y

Was this article helpful?