0

This is most likely completely noob and something simple ive missed but its been driving me mad all day and the IRC is not being very helpful :c

Using Laravel PHP Framework and routing is failing.

Environment:

  • Host machine Ubuntu 14.04
  • Guest Machine Laravel - Homestead Vanilla(Standard) Vagrant Box

Project:

Default unedited Composer Laravel Project

Behaviour

Navigate to /public you get the laravel project hello page(suggests friendly urls and routing is working fine). When you navigate to /account you get "No input file specified. "

The Code

                             -- app/routes.php --


    Route::get('/', function()
{
    return View::make('hello');
});

Route::get('/account', function()
{
    return View::make('account');
});

PLEASE NOTE HERE THAT THE ACCOUNT.PHP WAS CREATED IN THE VIEWS FOLDER

Nginx Error Logs

2014/06/24 06:56:49 [error] 1307#0: *97 FastCGI sent in stderr: "Unable to open primary script: /home/vagrant/Code/profile_system/index.php (No such file or directory)" while reading response header from upstream, client: 192.168.10.1, server: profile-system.app, request: "GET /accounts/create HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "profile-system.app"

So apparently the issue is that it cant find index.php in the / of the project. But laravel does not have an index.php in /.

Any ideas? See this link for complete environment info. happy to add anything else on request. https://gist.github.com/Jonjoe/6359e71e47b7a489109c

Laurence
  • 58,936
  • 21
  • 171
  • 212
Jonjoe
  • 171
  • 8

2 Answers2

1

If you navigate to /public to see Laravel's welcome page then your server is not configured properly. You should be able to get the welcome page without the /public in URL.

Probably the simplest way is to use .htaccess file (placed directly in Laravel directory) with the content:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

It is not the best solution though. You should threat your public directory as the website root instead of the Laravel directory. You can read more here.

Community
  • 1
  • 1
Linek
  • 1,353
  • 10
  • 20
  • Hmmm problem is im running the homestead vagrant box designed specifically for laravel. This should be working out of the box .. Just tried the .htaccess update and im getting the same result. I might just roll my own vagrant instead of using this premade. I appriciate your help though mate! – Jonjoe Jun 24 '14 at 13:39
  • @Jonjoe You might want to read this: [http://culttt.com/2013/06/17/setting-up-vagrant-with-laravel-4/](http://culttt.com/2013/06/17/setting-up-vagrant-with-laravel-4/) there is a section "Set up Apache" which tells you to set your VirtualHost to the `public` directory. – Linek Jun 24 '14 at 13:59
  • @Jonjoe You marked this as "accepted", but also mentioned that the .htaccess change still gave you the same error. I'm facing this issue as well, and I'm wondering how you ended up fixing it? – Thomas Kelley Sep 24 '14 at 14:41
0

Posting the answer because if you don't know it will destroy you.

Laraval applications start after /public. Make sure your hosts file / Web server specifies the path to be /root/to/project/laravel-root/public. THEN ITLL WORK :p.

Im going to mark Linek's answer as correct becuase if it was a friendly url issue that is the correct fix.

Jonjoe
  • 171
  • 8