在子域中部署laravel 4应用 [英] deploy laravel 4 app in a subdomain

查看:76
本文介绍了在子域中部署laravel 4应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在共享的Web主机上将laravel 4部署到一个子域中,对此我有些困惑.我在hostpapa帐户上使用它,但是对测试环境的配置和交换提供程序不满意.

I'm about to deploy laravel 4 on a shared web host into a subdomain and I'm a bit confused about what to do. I got it working on a hostpapa account but wasnt happy with the configuration and switched providers for the testing environment.

我创建了以下文件夹:

domain/private/myApps/golfmanager

domain/private/myApps/golfmanager

除了公用文件夹之外,我已经将所有文件和文件夹放在这里

I've placed in here all the files and folders except the public folder

然后我将公用文件夹的内容放入此文件夹:

I've then placed the contents of the public folder into this folder:

domain/subdomains/golfmanager/httpddocs

domain/subdomains/golfmanager/httpddocs

我不确定现在该怎么办!我了解我需要更改bootstrap/path.php中的路径

I'm not sure what to do now! I understand I need to change the paths in bootstrap/path.php

有人可以提供一些有关此文件夹设置需要更改的内容的指示.不想破坏它!

Can someone provide some pointers of what needs to be changed for this folder set up. Don't want to break it!!

谢谢

推荐答案

在共享主机上,这非常容易.

This is super easy on shared hosting.

步骤1:了解文件夹结构.共享主机的布局通常应如下所示:

Step 1: Understanding your folder structure. The layout of your shared hosting should generally look something like this:

/
 username
   home
     public_html
     subdomain-name
     laravel-files (optional)
     ...other folders etc

您希望知道,您站点的所有公共文件都将位于public_html文件夹中.

As you hopefully know, all your public files for your site will be in your public_html folder.

注意:有时,一个子域将位于public_html文件夹内.可以,但是我建议在根目录上方创建子域文件夹,以增加一点安全性.您可以在cPanel中轻松完成此操作,但是在创建子域时更改其路径.

Note: sometimes a subdomain will be inside the public_html folder. That is okay but I recommend creating your subdomain folder above the root for a little bit of extra security. You can do that easily in cPanel but changing the path to the subdomain when you are creating it.

第2步:如果您希望自己的Laravel文件更加整洁,请在根目录(在public_html上方)或子文件夹中上传您的Laravel文件.

Step 2: Upload your Laravel files above the root (above public_html) or in a subfolder if you want it to be cleaner.

对于一个小型项目,我通常将文件上传到上面的"home"文件夹中.但是,为了使结构更整洁,您可能需要在该主"文件夹中创建一个名为"laravel-files"的文件夹.

For a small project I generally upload the files into the "home" folder above. But for cleaner structure you may want to create a folder inside that "home" folder called "laravel-files".

接下来是如何在"laravel-files"文件夹中进行此操作.如果将它们上传到"home",那么您需要做的就是摆脱下面对"/laravel-files"的所有引用.

What follows is how to do it in an "laravel-files" folder. If you upload them to "home" instead then all you need to do is get rid of all references to "/laravel-files" below.

步骤3:编辑您的public/index.php和bootstrap/paths.php文件:

Step 3: edit your public/index.php and your bootstrap/paths.php files:

在paths.php中

更改

'app' => __DIR__.'/../app',

收件人:

'app' => __DIR__.'/../laravel-files/app',

更改:

'public' => __DIR__.'/../public',

收件人:

'public' => __DIR__,

更改:

'base' => __DIR__.'/..',

收件人:

'base' => __DIR__.'/../laravel-files',

更改:

'storage' => __DIR__.'/../app/storage',

收件人:

'storage' => __DIR__.'/../laravel-files/app/storage',

在index.php

更改:

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

收件人:

require __DIR__.'/../laravel-files/bootstrap/autoload.php';

更改:

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

收件人:

$app = require_once __DIR__.'/../laravel-files/bootstrap/start.php';

现在您需要做的是,正如我所说的,将laravel项目上载到"laravel文件"文件夹中.

Now what you'll need to do is, as I said upload your laravel project to your "laravel files" folder.

您唯一不上传的内容是laravel"public"文件夹的内容,而应将其上传到"subdomain-name"文件夹(包括index.php和所有CSS js文件等).

The only thing you wont upload there is the contents of your laravel "public" folder, which should instead be uploaded to your "subdomain-name" folder (this includes your index.php and all your css js files etc).

希望这会有所帮助!

请注意,我的回答基于以下问题:

Please note my answer is based on this question: How to install Laravel 4 to a web host subfolder without publicly exposing /app/ folder? but tailored for your situation.

这篇关于在子域中部署laravel 4应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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