0

This may look like the most basic of basic questions but it's been driving me nuts for an hour.

I just installed Laravel on my dedicated server, to a "test" directory, using

php composer.phar create-project laravel/laravel /home/my_username/public_html/test 4.2 --prefer-dist

All the right files/directories appeared in the "test" directory, I had to add the permission to "my_username" to edit the files with

chown -R my_username:my_username /home/my_username/public_html/test

...and I went in to edit the basic config. I only changed the URL from localhost to http://jovansprojects.com/test (feel free to visit) and I tried opening it in my browser.

However, instead of loading the default 'home' view (looking at the routes file, that's what it should do), it displays the list of files and folders in /test/. I have not changed anything in any files except app/config/app.php where I changed the URL, but that doesn't even seem to have anything to do with it, as when I change it to anything else, the problem remains.

This is the (default) routes.php file:

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

The hello.php view is present in the views folder as it should be.

The Laravel docs never seem to consider the possibility that the home view won't load upon installation, nor can I find this problem online.

So, any idea what the problem could be? Does Laravel need a specific port opened or something? Am I missing some config not mentioned in the installation and configuration guides?

1
  • In that list of files, you'll see a folder called public. Thats the one which is actually the directory you should be visiting in the browser. Commented Sep 17, 2015 at 11:07

1 Answer 1

2

Laravel keeps its main codebase above what should be the document root, or the public readable directory.

In your case, it's named public_html but Laravel names it public.

For the purpose of browsing your Laravel application in your case you simply need to visit

http://jovansprojects.com/test/public

What this means is you need to reorganise your folder structure slightly so that your document root points at Laravel's public folder.

As you're running Apache: If you can't do the above, or don't want to, you can disable directory listing by placing a file named .htaccess inside your test folder with the following contents.

Options -Indexes
Sign up to request clarification or add additional context in comments.

2 Comments

Ah I see, thanks for clearing that up. I suppose if I want to be able to open it through jovansprojects.com/test/ I have to fiddle with .htaccess?
You could do it with .htaccess or tweak some bootstrapping in your Laravel app, yes. There's a couple of guides here tutsnare.com/remove-public-from-url-laravel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.