3

I'd like to deploy a Laravel 5 app to a subdirectory of my web server root (public root being /public_html in this case as we're using Apache). The web server already has a non-Laravel site in the root public folder.

Most questions on this topic come down to using a subdomain instead of a subdirectory, however as we're using an organisational SSL cert without subdomain coverage we cannot do this.

I realise we could still plop the non-public resources above public_html, the public resources in a subdirectory and then hack at the paths required, but I haven't found any concrete instructions for how to achieve this. Is there a standard approach for this use case?

codinghands
  • 1,741
  • 2
  • 18
  • 31
  • It's for laravel 4, but this might help you : http://stackoverflow.com/questions/19923091/avoid-public-folder-of-laravel-and-open-directly-the-root-in-web-server – AntoineB Feb 17 '16 at 12:41

1 Answers1

1

You can create a sub-folder as public_html/new_project (or whatever name you give as per your coding conventions). And create another folder on the same level as the public_html for non-public resources as eg: new_project_resources.

  1. Now copy all everything except the public folder from your laravel project and upload it to the new_project_resources folder (on server).
  2. Open the public folder of your laravel project and copy everything and upload it to the public_html/new_project folder (on server).
  3. Now open index.php file from public_html/new_project and

    Change:  
    require __DIR__.'/../bootstrap/autoload.php';  
    To:  
    require __DIR__.'/../../new_project_resources/bootstrap/autoload.php';  
    And  
    Change:  
    $app = require_once __DIR__.'/../bootstrap/app.php';  
    To:  
    $app = require_once __DIR__.'/../../new_project_resources/bootstrap/app.php';  
    Save and Close.  
    
  4. Now go to new_project_resources folder and open server.php file

    Change:  
    require_once __DIR__.'../public/index.php';  
    To:  
    require_once __DIR__.'../public_html/new_project/index.php';  
    Save and close. 
    

    Things should work now from the subfolder. Hop it helps.

Donkarnash
  • 12,433
  • 5
  • 26
  • 37