Ubuntu 26.04

Apache2 : Use PHP Scripts2026/05/25

 

Configure Apache2 to use PHP scripts.

[1]

Install PHP, refer to here.

[2] Install PHP module for Apache2.
Note that Ubuntu default Apache httpd runs in [event MPM] mode, but installing [mod-php] will change it to [prefork MPM] mode.
If you do not want to change the operating mode to [prefork MPM], set PHP-FPM.
root@www:~#
apt -y install libapache2-mod-php
[3] Configure Apache2.
root@www:~#
vi /etc/php/8.5/apache2/php.ini
# line 964 : uncomment and add your timezone

date.timezone =
"Asia/Tokyo"
root@www:~#
systemctl reload apache2
# create a test page

root@www:~#
echo '<?php phpinfo(); ?>' > /var/www/html/info.php

[4] Verify to access to PHPInfo test page from any client computer.
Matched Content