9

I developed an application with laravel 4.2.8 and now I am having trouble deploying it. I followed this answer https://stackoverflow.com/a/16683938/3153380 but its not working. I am getting a white screen and the headers are returning a 500 Internal Server Error status.

I read around that laravel 4.2 is a bit tricky to set up on shared hosting is this true? I can seem to find a working solution so those that have deployed 4.2 before please help. My folder structure is like below

root/ laravel_base/ app/ ... public_html/ siteroot/ assets/ packages/ uploads/ index.php ... Any pointers?

Community
  • 1
  • 1
zinyando
  • 113
  • 1
  • 5
  • A "500 Internal Server Error" status code (or a blank page) means that your script is throwing an error but you haven't configured PHP to display error messages. That's something you need to fix before you go further; it's impossible to code properly without the aid of error messages. Here's a [brief explanation](http://stackoverflow.com/a/5680885/13508). – Álvaro González Sep 08 '14 at 12:46
  • @ÁlvaroG.Vicario thanks for the pointer. I got this error Warning: require(): open_basedir restriction in effect. File(/usr/www/users/hosting_base/laravel_base/../../siteroot/bootstrap/autoload.php) is not within the allowed path(s): – zinyando Sep 08 '14 at 12:54
  • If that's how the path looks like, your siteroot is outside your hosting_base. – Álvaro González Sep 08 '14 at 12:56

5 Answers5

18

First make sure that your shared host runs php >= v5.4. Second try to follow this steps:

  1. Create a folder outside your public_html/ or www/. Ex: project/
  2. Copy every folder and file (except the public folder) from your laravel app into that project/ folder
  3. Copy the content of public/ folder into your public_html/ or www/ (the .htaccess must be there too)
  4. Inside public/ locate the index.php file and change the following paths:

    a. Path to autoload.php

    require __DIR__.'/../bootstrap/autoload.php';
    

    into

    require __DIR__.'/../project/bootstrap/autoload.php';
    

    b. Path to start.php

    $app = require_once __DIR__.'/../bootstrap/start.php';
    

    into

    $app = require_once __DIR__.'/../project/bootstrap/start.php';`
    

After all that it should be working.

Abdillah
  • 982
  • 11
  • 28
Helder Lucas
  • 3,273
  • 2
  • 21
  • 26
  • I have created the folder outside de _'public_html'_ on my hosting and I have copied the **'public'** folder from my laravel projetc inside _'public_html'_. Now to access my app Do I need to specify the public folder too in the URL? I mean: **http://lenguajemx.com/public/** – alexventuraio Apr 06 '15 at 20:01
  • it probably can be two things. 1) Do you have public_html/public? if so make it only public_html/{contents here} 2) Have you copied the .htaccess too? – Helder Lucas Apr 08 '15 at 09:17
  • Yes both aspects are true, I have `public_html/public` and I have already copied the `.htaccess` inside the _public_html/public_ folder. So I'm going to do it as you said. Thanks I'm gonna try it again. – alexventuraio Apr 08 '15 at 20:27
4

I did something similar to @Helder Lucas - I also had to edit the bootstrap/paths.php file:

# change: 'public' => __DIR__.'/../public',
'public' => __DIR__.'/../../public_html',

I created a script to setup laravel projects for shared hosting environments. Here is the gist: https://gist.github.com/meganlkm/74dba6c4350ed58bf7bb

m79lkm
  • 2,960
  • 1
  • 22
  • 22
1

Try to play with .htaccess

In your public_html, add a .htaccess to forward the request

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^yoursite.com/public
    RewriteRule ^(.*)$ yoursite.com/public/$1 [L]
</IfModule>

i.e.

public_html
├── yoursite.com    <-------- laravel project
├── .htaccess       <-------- this file
Js Lim
  • 3,625
  • 6
  • 42
  • 80
0

It was pretty easy to get Laravel 4/5 running on OpenShift Online. For anyone else running into hosting issues, check out: https://hub.openshift.com/quickstarts/115-laravel-5-0

luciddreamz
  • 2,073
  • 14
  • 15
0

I just add a new folder in the / folder on my shared hosting

www.domain.com

Where i add a sub folder called

public/

So that the path looks like this

/www.domain.com/public/

And from the CPANEL i link the domain name root folder to the

www.domain.com/public/

And then i just upload the laravel application in

/www.domain.com

It works for laravel 4.2 and 5. And there is no security breaches because the root domain folder is in the public folder of the laravel app, no need for updating the .htaccess file.

It just works.