php – deploy laravel on nginx-ThrowExceptions

Exception or error:

My nginx and php have installed and run successfully.Enter URL http://127.0.0.1:8080/ in my browser will show ‘Welcome to NGINX’ page and when i run

php phpinfo.php

on terminal will display all the settings in my php.ini. I tried to run MY_SERVER_NAME/phpinfo.php will keep loading without showing anything. When i try to open my website with the MY_SERVER_NAME i set in nginx.conf, it will keep loading without showing anything too.

My web.conf listens to port 80 and original nginx.conf listens to port 8080

server{   
    listen 80;
    server_name MY_SERVER_NAME;
    root /...../public;
    index index.php index.html index.htm index.nginx-debian.html;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        try_files $uri /index.php=404;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
    } 
}

running sudo nginx -t display syntax is ok and test is successful

How to solve:

This should work!

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

    server_name SERVER_NAME; # server name of your choice. 

    root ROOT_DIRECTORY/public; # assumes the index.php is in public folder

    index index.php index.html index.htm index-nginx-debian.html;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php=404;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000; # assumes PHP listens on the port 9000
    } 
}

Leave a Reply

Your email address will not be published. Required fields are marked *