« Nginx and Ubuntu » : différence entre les versions

De Banane Atomic
Aller à la navigationAller à la recherche
Aucun résumé des modifications
Ligne 10 : Ligne 10 :


= Site configuration =
= Site configuration =
== default ==
<filebox fn='/etc/nginx/sites-available/default'>
server {
listen 80 default_server;  # listen port 80 and set as default server
listen [::]:80 default_server;
root /var/www/html;  # root path to the web site folder
index index.html index.htm index.nginx-debian.html;  # indexes
server_name _;  # server name: my-web-site.net
location / {
# First attempt to serve request as file, then as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
</filebox>
== phpinfo ==
== phpinfo ==
<filebox fn='/etc/nginx/sites-available/phpinfo.conf'>
<filebox fn='/etc/nginx/sites-available/phpinfo.conf' lang=nginx>
server {
server {
listen 80;
    listen 80;
 
    root /var/www/php;
root /var/www/php;
    index phpinfo.php;
 
    server_name phpinfo.net;
index phpinfo.php;


server_name phpinfo.net;  # server name: my-web-site.net
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;


location ~ \.php$ {
        # With php-fpm (or other unix sockets):
include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
    }
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
}
}
</filebox>
</filebox>

Version du 8 août 2023 à 21:36

Install

Bash.svg
ai nginx php-fpm

# check nginx and php-fpm are running
sc-status nginx
sc-status php8.2-fpm

Site configuration

phpinfo

/etc/nginx/sites-available/phpinfo.conf
server {
    listen 80;
    root /var/www/php;
    index phpinfo.php;
    server_name phpinfo.net;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;

        # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
    }
}