When I offer to create new user, I call it jack, you can use any other username.

NGINX & firewall

If you don't allow NGINX on firewall, your domain cannot be loaded.
sudo apt update
sudo apt install -y nginx

Configure firewall

sudo ufw allow 'Nginx HTTP'
sudo ufw allow 'Nginx HTTPS'
sudo ufw allow 'Nginx Full'

default NGINX

Virtual Host

sudo usermod -a -G www-data $USER

NGINX is setup but now, we have to setup Virtual hosts (or VHost). We take a basic example with just PHP 8.2 and an index.php, but it's same concept for any PHP app like Laravel or Symfony.

Create NGINX conf for this app

sudo vim /etc/nginx/sites-available/my-domain.localhost

Insert these infos and save file

server {
  listen 80;
  root /var/www/my-domain;
  index index.php index.html index.htm index.nginx-debian.html;
  server_name my-domain.localhost;

  location / {
    try_files $uri $uri/ =404;

  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;

  location ~ /\.ht {
    deny all;

Setup rights on web server folder /var/www, create root folder for the app and index.php

sudo chown -R $USER:www-data /var/www
sudo mkdir /var/www/my-domain
sudo touch /var/www/my-domain/index.php
sudo vim /var/www/my-domain/index.php

Fill index.php with basic infos

<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Domain</title>
  <div style="text-align: center; font-weight: bold; font-family: sans-serif; margin: 5rem 0">
    This is my new domain!

Make symbolic link with NGINX conf and sites-enabled to enable this conf, check NGINX configuration and reload NGINX to refresh web server

sudo ln -s /etc/nginx/sites-available/my-domain.localhost /etc/nginx/sites-enabled
sudo nginx -t
sudo service nginx reload

And now, you can access to you domain to http://my-domain.localhost

Next step: install and configure phpMyAdmin

Allow big files uploading

NGINX default conf allow 2 Mo files max in upload, if you want to change it follow these steps


sudo vim /etc/nginx/nginx.conf
Change or add this line
http {
  # ...
  client_max_body_size 500M;


Check PHP version used by your application, php -v give you just PHP CLI version, if don't setup VHost, it's PHP version of your app but if you have a VHost you have to check PHP version of conf. And update current php.iniFor example if current version is 8.2 (found with php --ini)
sudo vim /etc/php/8.2/fpm/php.ini
Search and change these lines
post_max_size = 500M
# ...
upload_max_filesize = 500M

Restart NGINX and PHP

sudo service nginx restart
sudo service php8.2-fpm restart

You can check with phpinfo().

PHP version and NGINX

When you execute php command into your terminal, you have a current PHP version than you can check it with php -v. But yours VHosts can always use old version of PHP, you will have to update NGINX conf for each VHost if you want to change their version of PHP (it's optional). You can keep VHost with old version of PHP, if you let this version on your system, it's useful to update version if you use modern syntax in your PHP app, for example type of parameters is available with latests PHP versions.

Following steps talks about VHost, if you don't know how it's works, read 4. Virtual Host before.

If you want to update a VHost NGINX conf, check it in /etc/nginx/sites-available/ and edit it, like:

sudo vim /etc/nginx/sites-available/my-domain

You will have some infos but search this line

server {
  # ...
  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

In this example, this VHost use PHP 7.2 version but if you installed PHP 8.0, you can update it

server {
  # ...
  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;

And your app will use new PHP version.

If you change PHP version, it can be missing some extensions, if your app display an error about extension check this part : missing extension


List virtual hosts with Nginx

grep server_name /etc/nginx/sites-enabled/* -RiI

Uninstall NGINX

sudo apt-get purge nginx nginx-common
sudo apt-get autoremove

VHost works on Chrome but not on Firefox

open Preferences -> Advanced -> Network open Settings and check manual proxy config and set proxy HTTP and port 80