Reputation: 849
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?
Upvotes: 0
Views: 1177
Reputation: 10569
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.
Upvotes: 0
Reputation: 632
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
Upvotes: 1