-
DEBIAN > installer nginx - PHPx.x - mariadb - PHPmyadmin
NOTE :
Le serveur se configure en root
su -
OS : Debian 12
IP : 192.168.1.10
1. Configurer le réseau
On configure la carte réseau en IP statique :
nmcli c modify nom-connexion ipv4.addresses 192.168.1.10/24 ipv4.gateway 192.168.1.254 ipv4.method manual
On renseigne le serveur DNS :
nmcli c modify nom-connexion ipv4.dns 1.1.1.1
On redémarre le service :
nmcli c down nom-connexion && nmcli c up nom-connexion
2. Nginx
apt install nginx
systemctl status nginx ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2018-07-07 12:10:05 UTC; 57s ago
si le serveur n’est pas démarré :
systemctl start nginx
masquer la version Nginx
vi /etc/nginx/nginx.conf http { ... server_tokens off; ... }
3. MariaDB
apt install mariadb-server mariadb-client
Si la version de MariaDB est obsolète :
apt-get install software-properties-common apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://sgp1.mirrors.digitalocean.com/mariadb/repo/10.3/ubuntu bionic main' apt update apt install mariadb-server
On vérifie que tout est OK :
systemctl status mysql ● mariadb.service - MariaDB database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2018-07-07 12:15:13 UTC; 2min 57s ago
administrateur (root) password
mysql_secure_installation
mysql -u root
4. PHP
apt install php-fpm php-mysql
Pour connaître la version de php-fpm installée :
systemctl list-unit-files | grep php php8.2-fpm.service
vi /etc/php/8.2/fpm/php.ini ;cgi.fix_pathinfo=1 # remplacer cette ligne ... cgi.fix_pathinfo=0 # ... par cette ligne
systemctl restart php8.2-fpm systemctl status php8.2-fpm ● php8.2-fpm.service - The PHP 8.2 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php8.2-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2018-07-07 12:23:46 UTC; 7s ago
Configurer Nginx pour PHP-FPM
ls /run/php/ php8.2-fpm.pid php8.2-fpm.sock php-fpm.sock
vi /etc/nginx/sites-available/default server { ... index index.php index.html index.htm; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php-fpm.sock; } }
On vérifie que tout est OK :
nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Si aucune erreur, redémarrer nginx :
systemctl restart nginx
page de test
vi /var/www/html/info.php
<?php phpinfo(); ?>
Redémarrer nginx, puis aller dans http://adresse_ip/info.php pour vérifier que la page s’affiche.
Configuration de PHP
Identifier le fichier de configuration :
php -i | grep php.ini Configuration File (php.ini) Path => /etc/php/7.2/cli Loaded Configuration File => /etc/php/7.2/cli/php.ini
/etc/php/7.2/fpm/php.ini :
post_max_size = 58M [...] upload_max_filesize = 52M
/etc/nginx/nginx.conf
http { client_max_body_size 12m;
Erreurs fréquentes
php8.2-fpm.sock failed : Permission denied
tail -f /var/log/nginx/error ==> error.log <== 2019/02/16 10:54:44 [crit] 13391#13391: *1 connect() to unix:/var/run/php/php8.2-fpm.sock failed (13: Permission denied) while connecting to upstream...
Le groupe www-data ne contient pas l’utilisateur nginx et donc, nginx n’est pas autorisé à se connecter au socket PHP-FPM.
usermod -a -G www-data nginx systemctl restart nginx
502 bad gateway
Peut-être que les droits ne sont pas bons pour php-fpm.sock :
si user toto dans
/etc/nginx/nginx.conf, véridier quell /var/run/php/php8.2-fpm.sock srw-rw---- 1 toto www-data 0 25 févr. 11:33 /var/run/php/php8.2-fpm.sock
sinon
chown toto:www-data /var/run/php/php8.2-fpm.sock systemctl restart nginx
5. PHPmyadmin
Créer un lien symbolique pour accéder à phpmyadmin
sudo ln -s /usr/share/phpmyadmin /chemin/phpmyadmin
voili voilou