itarafath said:

how to Setup Laravel 5 in Shared Hosting ?

This is a good option , supports laravel May from $ 3.5 / month www.hostinglaravel.com/planes.php

Another working solution: https:[email protected]/deploying-laravel-5-on-godaddy-shared-hosting-888ec96f64cd

I recently wrote an article on how I was able to host my laravel on a shared host. http://www.stuckcoders.com/how-to-host-your-laravel-project-in-a-shared-hosting/

Below are steps I've set on a hosting with cPanel without any changes in laravel_app:

  1. check out/copy laravel_app code to your home, /home/your_user/laravel_app

  2. set permissions:

chmod 755 /home/your_user/laravel_app/ chmod 755 /home/your_user/laravel_app/public/ chmod 644 /home/your_user/laravel_app/public/index.php chmod -R 777 /home/your_user/laravel_app/storage

  1. create symlink ln -s /home/your_user/laravel_app/public ~/public_html/laravel_app_public

  2. create ~/public_html/.htaccess following hoshomoh's instruction

Options -Indexes

RewriteEngine On RewriteCond %{REQUEST_URI} !^/laravel_app_public/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ laravel_app_public/$1 RewriteRule ^(/)?$ laravel_app_public/index.php [L]

How do you disable varnish cache in the .htaccess ??

One.com (shared host) keeps sending me this:
You add one line in your htaccess file in the root directory with only this "disablevcache" "true"
But suprise suprise, this does not work... !!
Is this meant to be in the .htaccess in the root folder??? And where do you put it if THIS is your .htaccess so far...

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

Thanks

ricksonchew said:

I've tried it on my shared hosting. Here's what I did.

  1. Install and setup laravel on your local (meaning you local machine)

  2. Once done, copy all files to your hosting.

  3. Create an .htaccess file on your laravel's root directory. This is to access it without the "public" on the url.

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{REQUEST_URI} !^public

RewriteRule ^(.*)$ public/$1 [L]

</IfModule>

This was simple and worked on Dreamhost for me.

  1. First make zip of your project.
  2. Upload it to the public_html or www according to your hosting.
  3. Extract it. Open your project.
  4. Move all files from public folder to your project main folder.
  5. Open index.php file. Change below two lines.

    require DIR.'/../bootstrap/autoload.php';
    $app = require_once DIR.'/../bootstrap/app.php';

to this

require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

6 Open server.php. Change below two lines

if ($uri !== '/' && file_exists(__DIR__.'/public/'.$uri))      
require_once __DIR__.'/public/index.php';

to this

if ($uri !== '/' && file_exists(__DIR__.'/'.$uri))
require_once __DIR__.'/index.php';

7 Open .htaccess file. Replace all with below lines

 DirectoryIndex index.php

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RedirectMatch 404 /\.git

RewriteEngine On

RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]

RewriteRule .? %{ENV:BASE}/index.php [L]

</IfModule>

8 Open .env file. Change

    APP_URL=http://localhost 

to this

    APP_URL=yourdomain

You can follow this step by step guide here. It's almost same as the solution accepted, but it would be more clear if we can refer a blog post on it http://justlaravel.com/how-to-deploy-laravel-project-shared-hosting/

HOSTING LARAVEL 5.4 PHP 7 Shared Hosting It offers web hosting for your projects in Laravel Framework all versions (4.x up to 5.4), we have support for PHP versions 5.3, 5.4, 5.5, 5.6, 7.0 and 7.1, up to 20 times faster thanks to the storage technology SSD. Http://hostinglaravel.com/

Hey Guys,

This is a probably very late solution but I hope it will help someone in future. Create a .htaccess and place the file in your laravel root directory. Then paste the following and save. It should solve all the problems regarding shared hosting and 404's being thrown when visiting any other pages apart from the homepage.

<IfModule mod_rewrite.c>
  RewriteEngine On
  # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
  #  slashes.
  # If your page resides at
  #  http://www.codestudio.club/mypage/test1
  # then use
  # RewriteBase /mypage/test1/
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.
  # Submitted by: [email protected]

  ErrorDocument 404 /index.php
</IfModule>

Probably a very late reply but may help others. I followed the same method as @luanntvn about the symlink process and in my opinion is the simplest approach for deploying a laravel application on a shared hosting. I had no problems in hosting my application and it runs great.