Table des matières

Nginx

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04

Install

sudo apt install nginx

Check

systemctl status nginx

http://localhost

Check Nginx configuration :

sudo nginx -t

Manage

sudo systemctl stop nginx

sudo systemctl start nginx

sudo systemctl restart nginx

sudo systemctl reload nginx

By default, Nginx is configured to start automatically when the server boots. If this is not what you want, you can disable this behavior by typing:

sudo systemctl disable nginx

To re-enable the service to start up at boot, you can type:

sudo systemctl enable nginx

Install PHP

sudo apt install php7.2-fpm

Nginx utilise une socket pour accéder à PHP.

Configure PHP

sudo vim /etc/php/7.2/fpm/pool.d/www.conf

Check listen = /var/run/php/php7.2-fpm.sock have the right socket path.

Configure site PHP

Dans la configuration de site PHP (/etc/nginx/sites-available/default) il faut vérifier que l'adresse de la socket est correcte :

        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }