0

Hey so I am completely new to Laravel 4 and have some basic questions regarding my first time installation that I was unable to find answers to anywhere else on-line. I am planning of hosting a standard website with a fully dynamic web back end and a RESTful API using the framework. I have been following this installation guide and am essentially at the part where I type laravel new projectDir and it creates a new instance of Laravel in the provided directory.

Now my main public directory is public_html, is it recommended to install Laravel 4 directly into that directory. So is something like laravel new public_html recommended? I have found many other questions here that seem to suggest that this is not the safest solution. Should I make a separate directory inside public_html, is it necessary for what I am planning on doing with laravel?

Also, I would like to keep my URL's as neat as possible and would like them primarily to be www.domain-name.com/pagename for the website. Will creating a directory inside of public_html disable me from doing so?

Lastly I had some issues with routing my URL's when I tried to install a different framework on this server. Are there any server/Apache settings that would impact how URL's are routed with laravel that I should disable/enable before I install Laravel into a directory?

ScottOBot
  • 839
  • 3
  • 16
  • 37

2 Answers2

1

you would not put the base Laravel folder in public_html.

In a Laravel directory structure, which gets created when you do the laravel new command, there is a directory called public. This is what you map your web root to. So on my vps, I have a folder called /var/site/mywebapp which was created by the command:

laravel new mywebapp

In nginx (which I much prefer over Apache), I map my server root to:

/var/sites/mywebapp/public

In the public folder is an index.php that Laravel uses to run your whole app/site. The rest of the framework is outside of the web root and is not accessible by HTTP.

As for your URL issues, consult the documentation for how to properly configure your mod_rewrite (assuming Apache).

Also, Dayle Rees, a prominent member of the Laravel community (and core contributor), has a github of sample web server configs here:

https://github.com/daylerees/laravel-website-configs

warspite
  • 622
  • 3
  • 12
  • Hey @warspite I set up laravel in a similar manner as your self. I have gone to Dayle Rees' github and changed the .htaccess in my main public_html folder with the one he provided for Apache (which is what I am using). I made the path changes where he indicated, but for some reason when I go to my web address I get a 500 error. What could I be doing wrong? – ScottOBot Feb 12 '14 at 03:10
  • As per my answer above, if you have configured the document root for Apache to point to your Laravel `/public` folder then it won't use public_html at all – warspite Feb 12 '14 at 09:52
  • ok I think I'm doing something really stupid with my Apache configuration and mod_rewrite possibly not being enabled. I will check it out let you know if it works and then give this one to your answer. Thanks again! – ScottOBot Feb 12 '14 at 14:56
  • if this helps, http://stackoverflow.com/questions/9021425/how-to-check-if-mod-rewrite-is-enabled-in-php gives you code to allow you to check if `mod_rewrite` is working – warspite Feb 12 '14 at 15:03
0

When you install Laravel it will create a public folder, along with app, bootstrap and vendor folders.

The public folder is essentially your public_html folder where you want your host/apache to point to when viewing the root of your website. So mydomain.com should land directly within the public folder.

You can rename the public folder to public_html just be sure to also update bootstrap/paths.php paths value

'public' => __DIR__.'/../public',
// change to
'public' => __DIR__.'/../public_html',

Laravel will create a .htaccess file for you, which will grab URLs and redirect them to public/index.php which will process Laravel accordingly.

So to answer the question, you install Laravel one folder back from public_html and then you can rename public to public_html if your host requires.

Bradley Flood
  • 10,233
  • 3
  • 46
  • 43