Apache2 mit PHP (Debian): Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 1: Zeile 1:
 
= Installation und Test von Apache2 mit PHP =
 
= Installation und Test von Apache2 mit PHP =
 
 
* apt install apache2 php libapache2-mod-php -y
 
* apt install apache2 php libapache2-mod-php -y
 
* systemctl enable --now apache2
 
* systemctl enable --now apache2

Version vom 13. November 2025, 16:47 Uhr

Installation und Test von Apache2 mit PHP

  • apt install apache2 php libapache2-mod-php -y
  • systemctl enable --now apache2
  • systemctl status apache2 --no-pager

PHP-Testseite anlegen

  • echo "<?php phpinfo(); ?>" > /var/www/html/info.php
  • chmod 644 /var/www/html/info.php
  • ls -l /var/www/html/info.php

Browser-Test

Im Browser aufrufen: http://10.20.10.11/info.php

Es sollte eine Seite mit den PHP-Informationen erscheinen (PHP Version, Module, Build-Datum etc.)

Logprüfung

  • tail -f /var/log/apache2/access.log
  • tail -f /var/log/apache2/error.log

Dynamischer Test (Hostname, Datum, Uhrzeit)

  • nano /var/www/html/test.php
<?php
echo "<h2>Serverstatus</h2>";
echo "Hostname: " . gethostname() . "<br>";
date_default_timezone_set("Europe/Berlin");
echo "Datum und Uhrzeit: " . date("Y-m-d H:i:s");
?>

Kontrolle

  • journalctl -u apache2 -n 20 --no-pager
  • systemctl reload apache2