【问题标题】:Installing Laravel in a subfolder [closed]在子文件夹中安装 Laravel [关闭]
【发布时间】:2012-09-28 18:16:13
【问题描述】:

我在子文件夹中找不到任何有关执行 Laravel 安装的信息。

甚至有可能做到这一点吗?还是在根级别安装 Laravel 要求?

我的托管服务提供商不允许我创建 VirtualHosts,我需要安装一个 Laravel 应用程序以及当前的应用程序...

UDPATE:原来这主要是一个 .htaccess 问题:

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

【问题讨论】:

  • 嗨@Pierlo Upitup,您是如何解决问题的。你能详细解释一下吗?问候。

标签: php apache laravel


【解决方案1】:

首先,考虑到这个答案只是为了让它工作,我不确定这可能对安全性产生任何影响,因为每个文件夹都在您网站的公共部分。

其次,我只是在安装准系统 laravel 时尝试过这个,所以我不确定这是否会在以后的开发中产生影响(我猜不是,但你永远不知道)。

1)复制根laravel文件夹(这是你的子文件夹)中public文件夹的所有内容

2) 您现在可以删除空的public 文件夹

3) 编辑index.php 并更改

// --------------------------------------------------------------
// Set the core Laravel path constants.
// --------------------------------------------------------------
require '../paths.php';

// --------------------------------------------------------------
// Set the core Laravel path constants.
// --------------------------------------------------------------
require './paths.php';

4) 编辑paths.php 并更改

// --------------------------------------------------------------
// The path to the public directory.
// --------------------------------------------------------------
$paths['public'] = 'public';

// --------------------------------------------------------------
// The path to the public directory.
// --------------------------------------------------------------
$paths['public'] = '.';

5) 编辑 laravel 文件夹中的 .htaccess 文件,使其不再重定向到 public

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

【讨论】:

  • 好吧,将 public 文件夹的所有内容移动到根目录已经不是我想要的,因为 css、img 和 js 文件夹会与其他安装发生冲突。另外,正如我所说,请记住,在根级别已经有另一个自定义框架,因此无法覆盖 /index.php 文件。
  • 根文件夹我指的是根laravel文件夹,你可以把它放到你安装的文件夹中,然后在www.yourdomain.com/laravelfolder访问它
  • 我按照您的指示操作,但收到 500 内部服务器错误。那会是什么?
  • 不看日志很难说。正如我所说,我在子文件夹中使用干净的 laravel 安装进行了尝试,它对我有用,但它可能不与所有配置兼容。我会检查日志,然后检查 .htaccess 文件,看看是否可以确定 500 的来源。
  • MAMP apache 日志说:由于可能的配置错误,请求超出了 10 次内部重定向的限制。如有必要,使用“LimitInternalRecursion”增加限制。使用“LogLevel debug”获取回溯。我的 htaccess 是 &lt;IfModule mod_rewrite.c&gt; RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule (.*) public/$1 [L] &lt;/IfModule&gt;
猜你喜欢
  • 2018-02-25
  • 1970-01-01
  • 2017-07-07
  • 1970-01-01
  • 2015-02-01
  • 1970-01-01
  • 2019-08-27
  • 2017-07-17
  • 2012-07-14
相关资源
最近更新 更多