在子文件夹中安装 Laravel
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12782699/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing Laravel in a subfolder
提问by Pierlo Upitup
I can't find any information whatsoever about performing a Laravel installation in a subfolder.
我找不到任何有关在子文件夹中执行 Laravel 安装的信息。
Is it even possible to do this? Or is it a Laravel requirement to be installed at root level?
甚至有可能做到这一点吗?还是需要在根级别安装 Laravel?
My hosting provider doesn't allow me to create VirtualHosts, and I need to install a Laravel application alongside what's currently up there...
我的托管服务提供商不允许我创建 VirtualHosts,我需要安装一个 Laravel 应用程序以及当前存在的内容......
UDPATE: turns out it was mainly an .htaccess issue:
UDPATE:原来这主要是一个 .htaccess 问题:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
回答by mrzard
First, take in consideration that this answer is just to make it work, I am not sure about any implications this may have in security due to every folder being in the public part of your site.
首先,请考虑到这个答案只是为了使它起作用,由于每个文件夹都位于您网站的公共部分,因此我不确定这可能对安全性有任何影响。
Second, I just tried this with a barebones laravel installation, so I'm not sure if this can have effects later in development (my guess is not, but you never know).
其次,我只是使用准系统 laravel 安装尝试了这个,所以我不确定这是否会在开发后期产生影响(我的猜测不是,但你永远不知道)。
1) Copy all the contents of the public
folder in the root laravel folder (which is your subfolder)
1)复制public
根laravel文件夹中文件夹的所有内容(这是你的子文件夹)
2) You can now remove the empty public
folder
2)您现在可以删除空public
文件夹
3) edit index.php
and change
3) 编辑index.php
和更改
// --------------------------------------------------------------
// Set the core Laravel path constants.
// --------------------------------------------------------------
require '../paths.php';
to
到
// --------------------------------------------------------------
// Set the core Laravel path constants.
// --------------------------------------------------------------
require './paths.php';
4) edit paths.php and change
4)编辑paths.php并更改
// --------------------------------------------------------------
// The path to the public directory.
// --------------------------------------------------------------
$paths['public'] = 'public';
to
到
// --------------------------------------------------------------
// The path to the public directory.
// --------------------------------------------------------------
$paths['public'] = '.';
5) Edit the .htaccess file in the laravel folder to make it redirect no more into public
5) 编辑 laravel 文件夹中的 .htaccess 文件,使其不再重定向到 public
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>