Setup Laravel 4 in Shared Hosting with securing Laravel base file

Assume that you have file structure something like this:-

/home/username/public_html
  1. Create new folder outside public_html:-
/home/username/main-laravel
  1. Move all the main file of Laravel (app, boostrap, vendor, composer.json, composer.lock, phpunit.xml etc) into that folder (step 1) **except Public folder

  2. Open /home/username/main-laravel/bootstrap/paths.php and edit to look like this:-

  3. replace 'app' => __DIR__.'/../app', to 'app' => __DIR__.'/../../main-laravel/app',

  4. replace 'public' => __DIR__.'/../public', to 'public' => __DIR__.'/../../public_html/laravel',

  5. replace 'base' => __DIR__.'/..', to 'base' => __DIR__.'/../../main-laravel',

  6. replace 'storage' => __DIR__.'/../app/storage', to 'storage' => __DIR__.'/../../main-laravel/app/storage',

—- SAVE —

  1. Now create a new folder inside public_html
/home/username/public_html/laravel
  1. Now, move all the content in public folder of Laravel into that folder (step 4)

  2. Open /home/username/public_html/laravel/index.php and edit to look like this:-

  3. replace require __DIR__.'/../bootstrap/autoload.php'; to require __DIR__.'/../../main-laravel/bootstrap/autoload.php';

  4. replace $app = require_once __DIR__.'/../bootstrap/start.php'; to $app = require_once __DIR__.'/../../main-laravel/bootstrap/start.php';

—- SAVE —

  1. Now create .htaccess in /home/username/public_html and insert this code:-
RewriteEngine on
RewriteCond %{REQUEST_URI} !^laravel
RewriteRule ^(.*)$ laravel/$1 [L]

—- SAVE —-

Now, your laravel website can be access at http://username.com


comments powered by Disqus