首页 文章

上传到服务器后,Laravel Application无法正常工作

提问于
浏览
5

我的laravel应用程序在本地服务器上运行良好 . 但是在我将它上传到我的服务器后它无法正常工作 . 我的应用程序的目录结构如下图所示:
enter image description here

我遇到了以下问题 . 它会自动重定向到没有显示任何内容的环回地址
enter image description here

这是我在服务器上的php版本

enter image description here

3 回答

  • 0

    我也遇到了麻烦 . 您需要做的是将“public”文件夹放在“www”目录中(如果使用虚拟机,则放在相应的public_html文件夹中) . 接下来,您必须将WHOLE应用程序放在您选择的目录中的var文件夹中,我们称之为“MySuperCoolFolder” . 最后,您必须修改index.php文件 . 更具体地说,这两行 .

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

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

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

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

    这应该做到这一点 . 如果它不起作用 . 转到文档并使用它们提供的.htaccess文件 . 这对我有用 .

    祝你好运!

    参考:https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e#.nvinp0r3e

  • 0

    确保您具有正确的Web服务器配置 . 您应该将Web服务器指向 public 目录并重新启动它 .

    此外,请确保您在 storage 目录上设置了正确的权限:

    chmod -R 775 storage
    

    并尝试清除所有缓存:

    php artisan cache:clear
    php artisan route:clear
    php artisan config:clear
    php artisan view:clear
    php artisan clear-compiled
    
  • 0

    试试访问http://127.0.0.1/Workshop/public_html

    Workshop文件夹中没有index.php或.htaccess . 这些通常是在公共场所,但看起来你有public_html

相关问题