Come installare Linux Apache MySQL PHP (LAMP) phpMyAdmin su openSUSE Tumbleweed

5 lug 2018 3 min di lettura
Come installare Linux Apache MySQL PHP (LAMP) phpMyAdmin su openSUSE Tumbleweed
Indice dei contenuti

Introduzione

LAMP è un gruppo di software open source che viene in genere installato insieme per consentire a un server di ospitare siti Web dinamici e app Web.
LAMP comprende Apache, MySQL, PHP.

In questo tutorial installeremo LAMP con PhpMyAdmin(Opzionale) su openSUSE Tumbleweed.

Installazione Apache

I repository ufficiali dei pacchetti di openSUSE includono una versione aggiornata di Apache, Possiamo quindi installare i pacchetti necessari usando zypper.

Aggiornare l'elenco dei pacchetti di openSUSE per avere la versione più recente degli elenchi del repository, da terminale:

sudo zypper su

Per installare Apache aprire il terminale e dare questi comandi:

sudo zypper install apache2

Per avviare Apache:

sudo systemctl start apache2

Per fare in modo che Apache si avvii in automatico all'avvio del server:

sudo systemctl enable apache2

Se il firewall di openSUSE è attivo dovete abilitare il traffico per Apache. Se la zona è stata cambiata, modificare public con la vostra zona:

sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --permanent --add-port=443/tcp

Riavviare il firewall:

firewall-cmd --reload

Per riavviare Apache:

sudo systemctl restart apache2

Per fermare Apache:

sudo systemctl stop apache2

Per verificare lo stato di Apache:

sudo service apache2 status

Creare un file html per controllare dal web se Apache funziona correttamente:

sudo nano /srv/www/htdocs/index.html

Incollare la seguente riga di codice:


<html><body><h1>Benvenuto sul mio sito!</h1></body></html>

Aprire il browser e connettersi all'indirizzo ip del proprio server oppure in locale:


http://localhost

http://SERVER_IP

Installazione MariaDB (MySQL)

Per installare MariaDB aprire il terminale e dare questo comando:

sudo zypper install mariadb mariadb-tools

Per avviare MariaDB:

sudo systemctl start mysql

Per fare in modo che MariaDB si avvii in automatico all'avvio del server:

sudo systemctl enable mysql

Per riavviare MariaDB:

sudo systemctl start mysql

Mettere in sicurezza MySQL

sudo mysql_secure_installation

Vi verrà chiesta la password dell'utente root, premere semplicemente invio poiché la password inizialmente non è presente.

Subito dopo vi verrà chiesto se la si vuole impostare, premere "y" quindi "si".

Per i successivi passaggi è consigliato premere "y".

  • Rimuovere gli utenti anonimi
  • Disabilitare il login root da remoto
  • Rimuovere il database test
  • Aggiornare le nuove regole

$ mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Installazione PHP

Per installare PHP da terminale:

sudo zypper install php7 php7-mysql php7-mbscript apache2-mod_php7 

Abilitare il modulo PHP con il comando:

sudo a2enmod php7

Riavviare Apache:

sudo service apache2 restart

Verificare la corretta installazione di PHP. Creiamo un file con estensione .php:

sudo nano /srv/www/htdocs/info.php

Incollare questo codice:


<?php phpinfo(); ?>

Salvare e chiudere il file.

Collegarsi al proprio indirizzo IP pubblico oppure in localhost:


http://localhost/info.php

Installare PhpMyAdmin
PhpMyAdmin è un'applicazione web che consente di utilizzare MySQL tramite il browser.

Per installare phpMyAdmin dare questi semplici comandi da terminale:

sudo zypper install phpMyAdmin

Abilitare mbscript:

sudo a2enmod php7-mbscript

Riavviare Apache:

sudo systemctl restart apache2

Ora per accedere all’interfaccia di PhpMyAdmin, aprire il browser e connettersi all'IP del vostro server oppure in localhost:


http://localhost/phpMyAdmin/ 

http://TUO_IP/phpMyAdmin/ 

L'installazione e configurazione base di un web server Apache con MySQL, PHP e PhpMyAdmin su openSUSE Tumbleweed è terminata.

Buy me a coffeeBuy me a coffee

Supportaci se ti piacciono i nostri contenuti. Grazie.

Successivamente, completa il checkout per l'accesso completo a Noviello.it.
Bentornato! Accesso eseguito correttamente.
Ti sei abbonato con successo a Noviello.it.
Successo! Il tuo account è completamente attivato, ora hai accesso a tutti i contenuti.
Operazione riuscita. Le tue informazioni di fatturazione sono state aggiornate.
La tua fatturazione non è stata aggiornata.