在子文件夹中安装Laravel [英] Installing Laravel in a subfolder

查看:176
本文介绍了在子文件夹中安装Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

它甚至有可能做到这一点?或者是在根级别要安装的Laravel要求?

我的托管服务提供商不允许我创建VirtualHosts,我需要安装Laravel应用程序一起什么是目前最多有...

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

 < IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php / $ 1 [L]
< / IfModule>


解决方案

首先,需要考虑这个答案只是为了使它工作,我不知道有任何影响,这可能有安全由于每个文件夹被您的网站的公共部分。

二,我只是试图与准系统laravel安装,所以我不知道这是否可以在以后的发展有特效(我的猜测是没有,但你永远不知道)。

1)公共文件夹中的所有内容(复制根文件夹laravel这是您的子文件夹)

2)您现在可以卸下空公共文件夹

3)修改的index.php 和变更

  // ------------------------------------ --------------------------
//设置核心Laravel路径常量。
// ------------------------------------------------ --------------
需要'../paths.php';

  // ------------------------------------ --------------------------
//设置核心Laravel路径常量。
// ------------------------------------------------ --------------
需要'./paths.php';

4)编辑paths.php和变更

  // ------------------------------------ --------------------------
//到公共目录的路径。
// ------------------------------------------------ --------------
$路径['公共'] ='公共';

  // ------------------------------------ --------------------------
//到公共目录的路径。
// ------------------------------------------------ --------------
'。'$路径['公共'] =;

5)编辑在laravel文件夹中的.htaccess文件,使之重定向没有更多进入公众

 < IfModule mod_rewrite.c>
    RewriteEngine叙述上
    的RewriteCond%{} REQUEST_FILENAME!-f
    的RewriteCond%{} REQUEST_FILENAME!-d
    重写规则^(。*)$的index.php / $ 1 [L]
< / IfModule>

I can't find any information whatsoever about performing a Laravel installation in a subfolder.

Is it even possible to do this? Or is it a Laravel requirement to be installed at root level?

My hosting provider doesn't allow me to create VirtualHosts, and I need to install a Laravel application alongside what's currently up there...

UDPATE: turns out it was mainly an .htaccess issue:

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

解决方案

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).

1) Copy all the contents of the public folder in the root laravel folder (which is your subfolder)

2) You can now remove the empty public folder

3) edit index.php and change

// --------------------------------------------------------------
// 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

// --------------------------------------------------------------
// 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

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

这篇关于在子文件夹中安装Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆