I was wondering if any of you know of a way to install Laravel 4 in a web host SUBDIRECTORY / subfolder while not exposing the /app/ folder and other sensible files to the publicly accesible part of the host.
The idea is, I'd be able to access http://mydomain.com/mylaravel/ to be able to use Laravel, but at the same time I want to avoid anyone doing something like going to http://mydomain.com/app/ or http://mydomain.com/mylaravel/app/ and basically being able to see my config files and other code.
If you want to simply setup Laravel Project on shared hosting and you have cPanel access then you can do following steps which I have followed and it worked well.
Step 1 : Make zip or tar file of your entire Laravel Application on your Local Machine.
Step 2 : Go to Cpanel. Upload zip/tar file to public_html directory and then extract it. (You can also create separate folder for your laravel application. As I want to upload more than one Laravel applications I have created separate directory for each one as shown in below image.)
Step 3 : Now go to 'Addon Domain' and change document root of your specified domain. Point the domain to public folder.
Now check your domain it will redirect to public/index.php file. There is no need to change any paths.
People, people! No need to over-complicate things!
(For other public folders, such as
htdocs
orwww
just replacepublic_html
in the following with your one.)app
folder is next to thepublic_html
folder)public
topublic_html
(be sure to also move hidden files, such as.htaccess
!)public
folderIn
bootstrap/path.php
change'public' => __DIR__.'/../public',
to'public' => __DIR__.'/../public_html',
emmanuel answer doesnt work for me but i did some changes to make it work . although i used my web root to be the source of a project . there it is ; i have htdocs folder as a root folder but you may have other, such as public_html , www or so on . you can easily replace my htdocs with the one you have .
fine .
my dircetory
first i solved all of laravel dependencies on my localhost on windows with composer . after that i did pack the whole package into laravel4.zip . in my htdocs i create a laravel folder and i did upload and unzip the zip file in it.
so after i did unzip the file i move everything in public folder into htdocs folder
now we have to rewrite some pathes in htdocs/index.php and htdocs/laravel/bootstrap/paths.php
but lets open htdocs/laravel/bootstrap/paths.php . you would see
what does it mean . it means that we are standing at htdocs/laravel/bootstrap/ path . and there for we need exit this folder to laravel folder then going for app folder . ok . this is the structure of the laravel for routing . if you get this right you can make your laravel run .
find
and change it to
(simple ha ) with one (../) of these we can go up one folder . so now we are at laravel folder . but we need to be in htdocs . so we have to write another (../) to get there .
open htdocs/index.php and find
change it into
require is a built-in php function so we are going to treat it as a simple php . we dont realy need laravel style for fetching autoload.php file . so simply remove it and go for classic style
find
change it into