deploy laravel 4 app in a subdomain

后端 未结 3 1322
我在风中等你
我在风中等你 2021-01-14 07:46

I\'m about to deploy laravel 4 on a shared web host into a subdomain and I\'m a bit confused about what to do. I got it working on a hostpapa account but wasnt happy with th

3条回答
  •  悲哀的现实
    2021-01-14 08:45

    Josh answer was very helpful, but it did not work or did not matched my case. I will tailor my solution like his one, so everyone could follow easily:

    Step 1: My chosen folder structure:

    /
     home
       username
         public_html
           subdomain-name
         laravel-files
         ...other folders etc
    

    Note: my subdomain is inside the public_html folder.

    Step 2: Uploaded my Laravel files above the root (above/out of public_html) in a subfolder: laravel-files (//home/username/laravel-files)

    Step 3: edit your public/index.php and your bootstrap/paths.php files:

    In paths.php

    Don't change:

    'app' => __DIR__.'/../app',
    

    to:

    'app' => __DIR__.'/../../laravel-files/app',
    

    because it's useless - it will evaluate to the following path:

    "/home/username/laravel-files/bootstrap/../../laravel-files/app"
    

    so the default is enough to just get out of bootstrap and enter app.

    Instead, change:

    'public' => __DIR__.'/../public',
    

    to:

    'public' => __DIR__.'/../../public_html/subdomain-name',
    

    Also, don't change: 'base' => DIR.'/..', 'storage' => DIR.'/../app/storage',

    In index.php

    change:

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

    to:

    require __DIR__.'/../../laravel-files/bootstrap/autoload.php';
    

    and change:

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

    to:

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

    Upload your laravel project to the "laravel-files" folder, except the public folder. Content of "public" folder, should instead be uploaded to the "subdomain-name" folder.

提交回复
热议问题