-
NGINX > installer PHP avec Nginx sans Apache
sudo apt update
PHP-FPM (FastCGI Process Manager) est une alternative à Apache pour exécuter du PHP:
sudo apt install php-fpm
Ouvrir le fichier de configuration de Nginx :
sudo nano /etc/nginx/sites-available/default
Modifier la section pour ressembler à ceci :
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.php index.html; server_name _; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } }
Remplacer php7.4-fpm.sock par la version obtenu en tapant /var/run/php/
Redémarrer Nginx :
sudo systemctl restart nginx
Test de PHP avec Nginx : Créez un fichier info.php dans /var/www/html :
<?php phpinfo(); ?>
Puis, dans Firefox, aller à http://localhost/info.php pour voir les infos sur PHP
Voili, voilou !