Come configurare un server web sul tuo VPS
Testato su Ubuntu/Debian/CentOS
Prerequisiti
-
Un VPS con accesso root/SSH
-
Conoscenza base della riga di comando Linux
-
10-15 minuti di tempo
1️⃣ Aggiorna il tuo sistema
# Per Ubuntu/Debian: sudo apt update && sudo apt upgrade -y # Per CentOS/RHEL: sudo yum update -y
2️⃣ Installa un server web
Opzione A: Apache (Facile e universale)
# Ubuntu/Debian: sudo apt install apache2 -y # CentOS: sudo yum install httpd -y
Avvia e abilita:
sudo systemctl start apache2 # o httpd (CentOS) sudo systemctl enable apache2
✅ Verifica: visita l’IP del tuo server nel browser. Dovresti vedere la pagina di test di Apache.
Opzione B: Nginx (Veloce e leggero)
sudo apt install nginx -y # Ubuntu/Debian sudo yum install nginx -y # CentOS
Avvia e abilita:
sudo systemctl start nginx sudo systemctl enable nginx
✅ Verifica: controlla http://[IP-del-tuo-server]
per la pagina di benvenuto di Nginx.
3️⃣ Installa MySQL/MariaDB (Database)
# Ubuntu/Debian: sudo apt install mariadb-server -y # CentOS: sudo yum install mariadb-server -y
Installazione sicura:
sudo mysql_secure_installation
(Segui le istruzioni per impostare la password root e rimuovere le impostazioni predefinite non sicure)
4️⃣ Installa PHP (Per contenuti dinamici)
# Ubuntu/Debian: sudo apt install php php-mysql -y # CentOS: sudo yum install php php-mysql -y
Testa PHP:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
✅ Visita http://[IP-del-tuo-server]/info.php
per vedere i dettagli PHP.
5️⃣ Configura il firewall
Consenti traffico HTTP/HTTPS:
# Ubuntu/Debian (UFW): sudo ufw allow 80/tcp sudo ufw allow 443/tcp # CentOS (FirewallD): sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reload
6️⃣ Avvio automatico dei servizi
Assicurati che i servizi si avviino automaticamente al riavvio:
# Per Apache: sudo systemctl enable apache2 # o httpd # Per Nginx: sudo systemctl enable nginx # Per MariaDB: sudo systemctl enable mariadb
Prossimi passi
-
Carica il tuo sito web tramite SFTP/FTP
-
Proteggi con SSL (Usa Let’s Encrypt):
sudo apt install certbot -y sudo certbot --apache # o --nginx
-
Ottimizza le prestazioni (Abilita la cache, usa PHP-FPM)
Consigli professionali
-
Ti serve un pannello di controllo? Prova:
-
Webmin (Gratis)
-
CyberPanel (Per OpenLiteSpeed)
-
-
Opzione Docker? Esegui Nginx/PHP in container per isolamento.
Esempio di stack LAMP in un comando (Ubuntu):
sudo apt update && sudo apt install apache2 mariadb-server php php-mysql -y && sudo mysql_secure_installation
Fatto!
Ora hai un server web self-hosted! Hai bisogno di aiuto? Contatta il supporto AuxoDomain.