Skip to content

Instantly share code, notes, and snippets.

@williwambu
Last active August 23, 2016 18:33
Show Gist options
  • Save williwambu/fc4b78aa723d0e8c7ec4 to your computer and use it in GitHub Desktop.
Save williwambu/fc4b78aa723d0e8c7ec4 to your computer and use it in GitHub Desktop.
Guide to configuring laravel on shared hosting
Laravel can can hosted in shared hosting environments. One can upload all files into puplic_html(www) folder.This comes with some problems:
- Exposes your code to the public
- To view the site you have to use http://your_domain/public or use url rewriting
To avoid this you have to separate the public folder from the other laravel files.
This is how i do it:
1. Create a folder above public_html or www in some environments. Call it laravel
2. Upload all the files in your laravel application to this folder except public folder
3.upload the contents of public folder to public_html or www
5.Change the application paths. Open laravel/app/bootstrap/paths.php and change
'public' => __DIR__.'/../public', to
'public' => __DIR__.'/../../www' or 'public' => __DIR__.'/../../public_html' if your hosting uses that name
6. Change www/index.php or public_html/index.php to locate the laravel folder
change:
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/start.php';
to:
require __DIR__.'/../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/start.php';
Everything should work perfectly now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment