Come installare Lighttpd MySQL PHP su Ubuntu 17.10

9 dic 2017 3 min di lettura
Come installare Lighttpd MySQL PHP su Ubuntu 17.10
Indice dei contenuti

Installazione Lighttpd

Per installare Lighttpd aprire il terminale e dare questi comandi:

sudo apt-get update
sudo apt-get -y install lighttpd

A questo punto il web server è pronto con le configurazioni di default.
Basta collegarsi al proprio indirizzo IP pubblico oppure in localhost:


http://localhost

Per riavviare Lighttpd:

sudo service lighttpd restart

Per fermare Lighttpd:

sudo service lighttpd stop

Per avviare Lighttpd:

sudo service lighttpd start

Installazione MySQL

Per installare MySQL aprire il terminale e dare questo comando:

sudo apt-get install mysql-server

Durante la fase di installazione vi verrà chiesto di inserire una password per l'utente root, che utilizzerete per accedere al server MySQL.

Mettere in sicurezza MySQL (Facoltativo)

sudo mysql_secure_installation

Inserire "y" per "si" oppure qualsiasi altra lettera per "no".

Nel primo passaggio inserire la password dell'utente root, in seguito vi verrà chiesto se si vuole testare la sicurezza della password e se la si vuole cambiare.

Per i successivi passaggi è consigliato premere "y" quindi "si".

  • 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-fpm da terminale:

sudo apt-get install php-fpm php-mysql

Per rendere l'installazione di PHP più sicura aprire questo file:

sudo nano /etc/php/7.1/fpm/php.ini

Trovare la riga ";cgi.fix_pathinfo=1". Decommentare e cambiare il valore in questo modo:


cgi.fix_pathinfo=0

Apire il seguente file per configurare PHP con lighttpd:

sudo nano /etc/lighttpd/conf-available/15-fastcgi-php.conf

Modificare il file in questo modo:


## Start an FastCGI server for php (needs the php7.1-cgi package)
fastcgi.server += ( ".php" =>
        ((
                "socket" => "/var/run/php/php7.1-fpm.sock",
                "broken-scriptfilename" => "enable"
        ))
)

Per abilitare le modifiche effettuate:

sudo lighttpd-enable-mod fastcgi
sudo lighttpd-enable-mod fastcgi-php

Creiamo un collegamento per le nuove configurazioni:

cd /etc/lighttpd/conf-available/
ls -l /etc/lighttpd/conf-enabled

Riavviare Lighttpd:

sudo service lighttpd force-reload

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

sudo nano /var/www/html/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

L'installazione e configurazione base di un web server Apache con MySQL e PHP è 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.