How to deploy laravel 4.2 on shared hosting?

后端 未结 5 1424
遇见更好的自我
遇见更好的自我 2020-12-09 06:00

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 worki

相关标签:
5条回答
  • 2020-12-09 06:42

    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

    0 讨论(0)
  • 2020-12-09 06:44

    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

    0 讨论(0)
  • 2020-12-09 06:46

    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
    
    0 讨论(0)
  • 2020-12-09 06:49

    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.

    0 讨论(0)
  • 2020-12-09 06:58

    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.

    0 讨论(0)
提交回复
热议问题