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

shahabes's avatar

Laravel blank page in NGINX

I'm using NGINX as my web server. I added the following ngingx config in /etc/nginx/sites-enabled/default. I Also checked the addresses in my index.php. But I faced with a blank page. Please help me solve the problem.

server {
    listen 80;
    server_name my.site;
    root /var/www/html/myFolder/;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
        index index.php index.html index.htm;
    charset utf-8;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    error_page 404 /index.php;
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ /\.(?!well-known).* {
        deny all;
    }
}
    

server {
    listen myIP:443 ssl;
    server_tokens off;
    ssl_certificate /root/certificates/letsencrypt/cert1.pem;
    ssl_certificate_key /root/certificates/letsencrypt/privkey1.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    server_name my.site;
    root /var/www/html/myFolder/;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
    index index.php index.html index.htm;
    charset utf-8;
    location / {
    try_files $uri $uri/ /index.php?$args;
    }
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    error_page 404 /index.php;
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ /\.(?!well-known).* {
        deny all;
    }
}
0 likes
2 replies
LaryAI's avatar
Level 58

It looks like your NGINX configuration is correct. The issue may be related to your Laravel application. To troubleshoot, you can try the following steps:

  1. Check your Laravel application's log files for any errors.
  2. Make sure your application's .env file is configured correctly.
  3. Make sure your application's storage folder is writable.
  4. Make sure your application's routes are configured correctly.
  5. Make sure your application's database connection is configured correctly.
  6. Make sure your application's cache is cleared. You can do this by running the following command:
php artisan cache:clear
  1. Make sure your application's configuration is cached. You can do this by running the following command:
php artisan config:cache

If none of these steps help, you can try running the following command to check for any syntax errors in your application's code:

php artisan optimize

If you still can't find the issue, you can try enabling debug mode in your application's .env file by setting the APP_DEBUG variable to true. This will enable more detailed error messages that may help you identify the issue.

I hope this helps!

arkadiy's avatar

Try to change root directive to root /var/www/html/myFolder/public; And be sure to run composer install on the server in /var/www/html/myFolder/

Please or to participate in this conversation.