Laravel 5.5 |从生产服务器迁移到本地安装(laragon)|尴尬链接到公用文件夹

时间:2019-06-14 08:14:43

标签: laravel-5 migration

我将我的应用程序副本从生产服务器迁移到本地计算机(laragon)。

与数据库的连接工作正常,只是链接断开有问题|当我加载主页时,URL指向CSS和JS文件,导致没有样式,如您在所附图像中看到的那样:

enter image description here

在迁移我的应用程序之后,我移动了以下文件:

.htaccess
favicon.ico
index.php
robots.txt
web.config

从根目录到公用文件夹。

我在index.php文件中更改了以下内容:

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__.'bootstrap/autoload.php';

to

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

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

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

to

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

在环境中。我设置的文件:

APP_URL=http://localhost

作为应用程序网址

控制台错误包括以下内容:

bootstrap.min.css
url : http://mage.local/public/public/vendor/crudbooster/assets/adminlte/bootstrap/css/bootstrap.min.css
Failed to load resource: the server responded with a status of 404 (Not Found)


AdminLTE.min.css
url : http://mage.local/public/public/vendor/crudbooster/assets/adminlte/dist/css/AdminLTE.min.css
Failed to load resource: the server responded with a status of 404 (Not Found)

我通过查看具有两次公用文件夹设置的url看到了错误:

.../public/public/...

但是我不知道如何解决这个问题。在此感谢您的专业知识。谢谢。

1 个答案:

答案 0 :(得分:0)

解决方案:

感谢@snapey,一个laracasts专家撰稿人,如果您不像我这样使用github,那么解决方案实际上很简单:

  1. 将整个应用复制到本地文件夹中
  2. 请勿更改Laravel App配置中的任何内容
  3. 相应地更改虚拟主机文档的根目录(对于使用Laragon的我来说,我只是添加到菜单:Apache |已启用站点|并选择与您的站点相关的文件,在我的情况下为auto.APPNAME.local.cong
<VirtualHost *:80> 
    DocumentRoot "F:/PROJECTS/www/APPNAME/"
    ServerName mage.local
    ServerAlias *.mage.local
    <Directory "F:/PROJECTS/www/APPNAME/">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

ATTENTION shouldn't be done on a production server for security issues (since data in public folder would be accessible), but since it is local, no problem for me.

就我而言:

   DocumentRoot "F:/PROJECTS/www/APPNAME/public/"

我在更改它:

   DocumentRoot "F:/PROJECTS/www/APPNAME/"

神奇的是它按预期运行,Bootstrap CSS又回来了。

相关问题