Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Inquisitive's avatar

This site can’t be reached, on nginx, debian 11

I have done this in a fresh Debian installation on the server.

sudo apt install nginx
sudo systemctl start nginx
sudo systemctl status nginx
curl -sSL https://packages.sury.org/php/apt.gpg -o sury-php.gpg
sudo mv sury-php.gpg /etc/apt/trusted.gpg.d/
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

sudo apt update
sudo apt upgrade

sudo apt install -y php8.2-fpm php8.2-common php8.2-mysql php8.2-xml php8.2-xmlrpc php8.2-curl php8.2-gd php8.2-imagick php8.2-cli php8.2-dev php8.2-imap php8.2-mbstring php8.2-opcache php8.2-soap php8.2-zip php8.2-intl

sudo service php8.2-fpm restart
sudo rm /etc/nginx/sites-enabled/example.com

server {
    listen 80;
    listen [::]:80;

    server_name example.com www.example.com;
    root /var/www/example.com/public;
    
    index index.html index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

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

    location ~ /\.ht {
        deny all;
    }
}

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
sudo nginx -t
sudo systemctl restart nginx

now on /var/www/example.com/public, I have created a dummy index.php file with echo Hello world.

Nothing showing in error and access log. How could I debug this? By the way on IP, it is showing the welcome nginx page, it could be because of fallback to the default server configuration. What I might be missing?

0 likes
1 reply
LaryAI's avatar
Level 58

Based on the provided information, it seems like the server block configuration for the example.com domain is not properly set up in the Nginx configuration file. Here are some steps to try and debug the issue:

  1. Check the Nginx error log file for any errors or warnings related to the example.com domain. The error log file is usually located at /var/log/nginx/error.log. You can use the tail command to view the last few lines of the log file in real-time:

    sudo tail -f /var/log/nginx/error.log
    
  2. Check the Nginx access log file to see if any requests are being made to the example.com domain. The access log file is usually located at /var/log/nginx/access.log. You can use the tail command to view the last few lines of the log file in real-time:

    sudo tail -f /var/log/nginx/access.log
    
  3. Check the Nginx configuration file to make sure that the server block for the example.com domain is properly set up. You can use the cat command to view the contents of the file:

    sudo cat /etc/nginx/sites-available/example.com
    

    Make sure that the server_name directive is set to the correct domain name, and that the root directive points to the correct document root directory.

  4. Check the PHP-FPM log file to see if there are any errors related to the example.com domain. The log file is usually located at /var/log/php8.2-fpm.log. You can use the tail command to view the last few lines of the log file in real-time:

    sudo tail -f /var/log/php8.2-fpm.log
    

    If there are any errors related to the example.com domain, they should be logged here.

  5. Check the permissions of the document root directory and the index.php file. Make sure that the Nginx user (usually www-data) has read and execute permissions on the directory and file:

    sudo chown -R www-data:www-data /var/www/example.com/public
    sudo chmod -R 755 /var/www/example.com/public
    

    This will give the Nginx user read and execute permissions on the directory and file.

  6. Finally, make sure that the DNS records for the example.com domain are properly set up and pointing to the correct IP address. You can use the nslookup command to check the DNS records:

    nslookup example.com
    

    This should return the IP address that the domain is pointing to. Make sure that this IP address matches the IP address of your server.

If none of these steps help to resolve the issue, you may need to provide more information or seek further assistance from the Nginx or PHP-FPM communities.

Please or to participate in this conversation.