LEMP

La pile LEMP (Linux, Nginx, MySQL, PHP) permet un hébergement web rapide, sécurisé et fiable.

Services installés

  • Serveur Web Nginx → /var/www/html
  • Serveur MySQL (sécurisé) → Identifiants root stockés à l'adresse /root/.cloudzy-creds
  • PHP et extensions → Inclusions php-fpm, php-mysql, php-cli, php-curl, php-mbstring, php-xml, php-zip, php-gd

Fichiers et répertoires importants

  • Mot de passe root MySQL enregistré : /root/.cloudzy-creds
  • Répertoire racine Web Nginx : /var/www/html
  • Fichiers de configuration Nginx : /etc/nginx
  • Fichiers de configuration MySQL : /etc/mysql
  • Fichiers de base de données MySQL : /var/lib/mysql
  • Journaux Nginx : /var/log/nginx
  • Journaux MySQL : /var/log/mysql
  • Socket PHP-FPM : /run/php/php-fpm.sock

Accéder à MySQL

Connectez-vous en tant qu'administrateur :

mysql -u root -p

Le mot de passe est stocké dans /root/.cloudzy-creds.

Commandes courantes :

SHOW DATABASES;                                              -- List all databases
USE <database>;                                              -- Switch to a specific database
CREATE DATABASE mydb;                                        -- Create a new database
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'password';  -- Create a new user
GRANT ALL PRIVILEGES ON mydb.* TO 'appuser'@'localhost';     -- Grant privileges
EXIT;                                                        -- Quit MySQL shell

Accéder à Nginx

Racine Web : /var/www/html

Test de configuration :

sudo nginx -t

Accès dans le navigateur : http://<SERVER_IP>

Utilisez PHP

Vérifier la version :

php -v

Gestion des services

Nginx :

sudo systemctl status nginx    # Check status
sudo systemctl restart nginx   # Restart service

MySQL :

sudo systemctl status mysql     # Check status
sudo systemctl restart mysql    # Restart service

PHP-FPM :

PHP_FPM_VERSION=$(ls /etc/php | grep -E '^[0-9]+.[0-9]+$')
PHP_FPM_SERVICE="php${PHP_FPM_VERSION}-fpm"
systemctl status ${PHP_FPM_SERVICE}
systemctl restart ${PHP_FPM_SERVICE}

Détails de la demande