Installare un Web Server LAMP completo su Debian 12
Guida passo-passo per configurare un web server production-ready con Apache, PHP 8.2 e MariaDB su Debian 12 Bookworm.
1. Aggiornamento sistema
apt update && apt upgrade -y
2. Installazione Apache
apt install -y apache2
systemctl enable apache2
systemctl start apache2
Verifica: apri http://IP-SERVER nel browser. Dovresti vedere la pagina default di Apache.
3. Installazione PHP 8.2
apt install -y php8.2 libapache2-mod-php8.2 php8.2-mysql php8.2-curl php8.2-gd php8.2-mbstring php8.2-xml php8.2-zip php8.2-intl
php -v
4. Installazione MariaDB
apt install -y mariadb-server
systemctl enable mariadb
mysql_secure_installation
Rispondi Y a tutte le domande per hardening del database.
5. Configurazione VirtualHost
nano /etc/apache2/sites-available/miosito.conf
<VirtualHost *:80>
ServerName miosito.it
DocumentRoot /var/www/miosito
<Directory /var/www/miosito>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/miosito-error.log
CustomLog ${APACHE_LOG_DIR}/miosito-access.log combined
</VirtualHost>
mkdir -p /var/www/miosito
a2ensite miosito.conf
a2enmod rewrite
systemctl reload apache2
6. Test PHP
echo "<?php phpinfo();" > /var/www/miosito/info.php
Apri http://IP-SERVER/info.php e verifica. Poi elimina il file: rm /var/www/miosito/info.php
7. Firewall UFW
apt install -y ufw
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
Risultato: Web server LAMP pronto per la produzione con Apache, PHP 8.2 e MariaDB su Debian 12.