Pré-requis
Ajout des dépots
echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list
echo "deb http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list
echo "deb-src http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list
Création des certificats
cd /tmp
wget http://nginx.org/keys/nginx_signing.key
wget https://www.dotdeb.org/dotdeb.gpg
apt-key add nginx_signing.key
apt-key add dotdeb.gpg
Installation et configuration des paquets
apt-get update
apt-get install nginx php7.0-mysql php7.0-fpm php7.0-curl
apt-get install mariadb-server mariadb-client
mysql_secure_installation
nano /etc/php/7.0/fpm/php.ini
nano /etc/nginx/nginx.conf
mv /etc/nginx/conf.d/default.conf /etc/nginx/default.conf.bak
Configurer NGINX
nano /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.php index.html index.htm;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Redémarrage des services
systemctl restart nginx.service && systemctl restart php7.0-fpm.service
Test du serveur (Nginx et PHP)
Tester PHP7 en créant une page de test et en donnant les droits à NGINX de les utilisers
Création d'une page de test PHP
mkdir -p /var/www/html
echo '<?php phpinfo(); ?>' > /var/www/html/index.php
Définition des droits
chown -R www-data:www-data /var/www/
Redémarrage des services
systemctl restart nginx.service && systemctl restart php7.0-fpm.service