[LXLE] Installation de Apache2, MySQL, PHP.

Distribution de travail : LXLE 18.04 Hostname : server.local

1/ Mise-à-jour du système.

util01@server:~$ sudo apt update util01@server:~$ sudo apt upgrade

2/ Installaton de Apache2.

util01@server:~$ sudo apt install apache2

3/ Configuration du pare-feu.

util01@server:~$ sudo ufw allow in "Apache Full"

4/ Test.

http://server.local/

5/ Installation de MySQL.

util01@server:~$ sudo apt install mysql-server

6/ Sécurisation de MySQL.

util01@server:~$ sudo mysql_secure_installation Press y|Y for Yes, any other key for No: New password: Re-enter new password: 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 util01@server:~$

7/ Changement de la méthode d'authentification pour l'utilisateur MySQL 'root'.

util01@server:~$ sudo mysql mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mot2passe'; mysql> FLUSH PRIVILEGES; mysql> EXIT;

8/ Installation de PHP.

util01@server:~$ sudo apt install php libapache2-mod-php php-mysql

9/ Redémarrer le serveur Apache2.

util01@server:~$ sudo systemctl restart apache2

10/ Test.

Créer : /var/www/html/info.php Ajouter : <?php phpinfo(); ?> Adresse : http://server.local/info.php

11/ Installation de PhpMyAdmin.

util01@server:~$ sudo apt-get install phpmyadmin Adresse : http://server.local/phpmyadmin/

12/ Configuration du répertire 'public_html' pour les utilisateurs.

Ouvrir : /etc/apache2/mods-available/php7.2.conf Chercher et commenter : <Directory /home/*/public_html> php_admin_flag engine Off </Directory> Action : util01@server:~$ sudo a2enmod userdir util01@server:~$ sudo systemctl restart apache2

13/ Test.

util01@server:~$ mkdir public_html Ouvrir : ~/public_html/index.php Ajouter : <?php echo "Utilisateur util01"; ?> Adresse : http://server.local/~util01/

14/ Lien.

https://www.ostechnix.com/install-apache-mysql-php-lamp-stack-on-ubuntu-18-04-lts/