Nginx and Ubuntu
Apparence
Install
ai nginx php-fpm
# check nginx and php-fpm are running
sc-status nginx
sc-status php8.2-fpm
|
Site configuration
default
/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;
}
}
|
phpinfo
/etc/nginx/sites-available/phpinfo.conf |
server {
listen 80;
root /var/www/php;
index phpinfo.php;
server_name phpinfo.net; # server name: my-web-site.net
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
}
|