30 Aprile 2025

Appunti informatici

Il quaderno degli appunti informatici

Installazione Lamp server su Raspbian/Ubuntu

2 min read

Per installare un Linux Apache Mysql php server su Raspbian e/o Ubuntu, nel mio caso la 18.04 lanciare i seguenti comando nella shell:

sudo apt update
sudo apt install apache2
sudo apt install mariadb-server mariadb-client sudo mysql_secure_installation

Rispondete “yes” alle domande

Set root password? [Y/n]: y
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
sudo apt install php php-common php-mysql php-gd php-cli 

Per verificare se tutto funziona:

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

Se è andato tutto bene accedendo alla porta 80 del web server dovrebbe apparire:

Ora installiamo phpmyadmin, selezionando apache2, “Si” ed inserendo la password del database alle richieste presentate durante l’installazione:

sudo apt install phpmyadmin
Selezionare Apache2
Selezionare “Si”
 Password Mysql
Conferma della password
sudo systemctl restart apache2

A questo punto phpmyadmin dovrebbe essere disponibile http://ServerIP/phpmyadmin/index.php

Dalla versione Mysql 5.7 l’accesso Root è disabilitato quindi è necessario creare un nuovo utente con account admin:

sudo mysql -u root -p

MariaDB [(none)]> CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> quit

Eccolo in funzione

phpmyadmin funzionante

Per far caricare automaticamente  il file index.php va modificato il file /etc/apache2/sites-enabled/000-default.conf aggiungendo que:

DirectoryIndex index.html index.php

Per abilitare il modulo mod_rewrite

sudo a2enmod rewrite

sudo systemctl restart apache2

About Author

Lascia un commento