0

I'm trying to use the Laravel 4.2 on nginx. I have a VPS (Dreamhost) and I put the Laravel framework inside the root path of user (/home/vi360/) and the public path is on /home/vi360/vide360.com.br

I've been researching several ways to set up nginx for Laravel, but I'm not getting any success. Only the home page is opening (www.vide360.com.br), but all the other pages (directed by /home/vi360/app/routes.php) are returning with error 404.

I have created the /home/vi360/nginx/vide360.com.br/vide360.conf as follows:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /home/vi360/vide360.com.br;
    index index.php index.html index.htm;

    server_name [server ip address];

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

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

What am I maybe doing wrong?

Paulie-C
  • 1,674
  • 1
  • 13
  • 29
Daniel Groppo
  • 59
  • 1
  • 1
  • 7

1 Answers1

1

I guess you changed the public folder name.

Laravel looks up its files in public folder. Say your laravel application running on /home/vi360 then your public folder path will be /home/vi360/public.

Then on your nginx, it should be like

root /home/vi360/public;

Try renaming the vide360.com.br folder back to public and it will be fine. This is because the framework follows the request by booting up and forwarding it to public/index.php file.

Don't forget to restart nginx and php-fpm after the settings change.

EDIT

If the developer wants to change the public directory of laravel from public folder to other folder, say vide360.com.br, then edit your Application Service Provider (ASP) which is located at App\Providers\AppServiceProvider.php. And under the register method add the code with your new public folder name.

 $this->app->bind('path.public', function() {
        return base_path().'/vide360.com.br';
    });
Arun Code
  • 1,548
  • 1
  • 13
  • 18
  • Thank you for your reply! I already changed the '/home/vi360/boostrap/path.php' to recognize the public folder as 'vide360.com.br' (It is the default path for public of server). Btw, if the index page is opening, the framworking is bootstraping well, am I right? – Daniel Groppo Jun 26 '17 at 17:02
  • @DanielGroppo code updated to your scenario. You have to bind the new location to the app so that the code can detect it. Changing bootstrap path will only send the request to your new folder, not the app to detect the new location. – Arun Code Jun 27 '17 at 03:24