Method 1 - Install Laravel using Composer on shared hosting
The procedure for installing Laravel 5 on shared hosting with Apache and cPanel
-
Connect to hosting via SSH
-
In cPanel open Select PHP version and choose 5.4. (I also set phar extension)
-
Install Laravel
php composer.phar create-project laravel/laravel myproject --prefer-dist
-
Copy everything from myproject/public to public_html
-
open public_html/index.php and set:
require DIR.'/../myproject/bootstrap/autoload.php';
$app = require_once DIR.'/../myproject/bootstrap/start.php';
Also, add this to the top of index.php:
ini_set('eaccelerator.enable', 0);
Method 2 - copy Laravel install to shared hosting
I've tried it on my shared hosting. Here's what I did.
-
Install and setup Laravel on your local (meaning your local machine)
-
Once done, copy all files to your hosting.
-
Create a .htaccess file on your Laravel's root directory. This is to access it without the "public" on the URL.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
Method 3 - Bluehost Laravel shared hosting
- Setup a project Laravel 5 in localhost correctly configured
- Double check the server configuration of PHP 5.4
- This is because every little change on .htaccess file may change that config
- Create a directory in the same level of public_html and put the project inside of that folder.
- Put the content of public (Laravel 5) directly on public_html (be aware of not overwriting the .htaccess file accidentally)
Now... This is the "tricky part"... actually not xD In Bluehost I see this structure
- perl5
- php
- public_html
- [framework-folder]
- ssl
Inside of public_html I can see all the files of public directory of Laravel 5
Go to index.php and edit the line 22
#From this
require __DIR__.'/../bootstrap/autoload.php';
#To this
require __DIR__.'/../[framework-folder]/bootstrap/autoload.php';
And the line 36
#From this
$app = require_once __DIR__.'/../bootstrap/app.php';
#To this
$app = require_once __DIR__.'/../[framework-folder]/pulcro/bootstrap/app.php';
The final step is to edit the .htaccess file and add some lines
RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} !^
RewriteRule ^(.*)$ /$1 [L]
Refresh the cache of my browser and.. Victory!!
I know that this is not the absolute right way to install the framework (God, I never spoke about Composer)
Source: Laravel.io