简体   繁体   English

在共享托管服务器上的sub doamin中设置laravel 5.2

[英]setting up laravel 5.2 in a sub doamin at a shared hosting server

I want to deploy laravel 5.2 into a sub domain named sub but i get the following error 我想将laravel 5.2部署到名为sub的子域中,但是我得到以下错误

Unable to handle the request 无法处理请求
HTTP ERROR 50 HTTP错误50

I have researhed and found that i require php version 5.5.9 and above in order for laravel to run. 我已经研究并发现我需要php版本5.5.9及更高版本才能运行laravel。 I have laravel 5.5, but When i place laravel "public" folder contents into the shared host "public_html" folder it works but when i place the same content into my sub domain its not working. 我有laravel 5.5,但是当我将laravel“public”文件夹内容放入共享主机“public_html”文件夹时,它可以工作,但是当我将相同的内容放入我的子域时,它无法正常工作。

i have also changed the index.php as follows 我也改变了index.php如下

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

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

After you meet the server requirements , You only need to point your subdomain to the public directory of your laravel project directory. 满足服务器要求后 ,只需将子域指向laravel项目目录的public目录即可。

eg if your domain is enaveed.com , your subdomain is flipflop.enaveed.com and your project is in /public_html/flipflop directory, this is how you need to configure your subdomain in a standard cpanel environment: 例如,如果您的域名是enaveed.com ,你的子域名是flipflop.enaveed.com和你的项目中/public_html/flipflop目录,这是你需要如何配置你的子域在一个标准的cPanel环境:

标准cpanel视图

First, you should met the server requirement: https://laravel.com/docs/5.2/installation#server-requirements 首先,您应该满足服务器要求: https//laravel.com/docs/5.2/installation#server-requirements

Second, you should upload all the files of laravel into your public_html 其次,你应该将laravel的所有文件上传到你的public_html中

Third, change the name of server.php to index.php 第三,将server.php的名称更改为index.php

fourth, copy .htaccess file from laravel "public" folder to your public_html 第四步,将laravel“public”文件夹中的.htaccess文件复制到你的public_html

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

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

Those paths look wrong. 那些路径看起来不对。

  • First, Copy everything except public folder in your root folder(preferably not in public_html but one level up, so people cannot access them) and give a name to folder. 首先,复制根文件夹中除公共文件夹之外的所有内容(最好不要在public_html中,但不能在一级中复制,因此人们无法访问它们)并为文件夹命名。 Let's say the folder name is laravel. 假设文件夹名称是laravel。
  • Copy your public folder in to your public folder(public_html), then, rename it to "sub". 将您的公用文件夹复制到您的公用文件夹(public_html),然后将其重命名为“sub”。 So you can access it by http://www.yourwebsite.com/sub . 因此,您可以通过http://www.yourwebsite.com/sub访问它。
  • in index.html file in your sub folder, change the paths like below. 文件夹的index.html文件中,更改如下所示的路径。

    require DIR .'/../../laravel/bootstrap/autoload.php'; 需要DIR 。'/ .. / .. / laravel / bootstrap / autoload.php';
    $app = require_once DIR .'/../../laravel/bootstrap/app.php'; $ app = require_once DIR 。'/ .. / .. / laravel / bootstrap / app.php';

    • Go to bootstrap/app.php file, then change below 转到bootstrap / app.php文件,然后在下面进行更改

$app = new Illuminate\\Foundation\\Application( $ app = new Illuminate \\ Foundation \\ Application(
realpath( DIR .'/../') realpath( DIR 。'/ .. /')
); );

to

$app = new Illuminate\Foundation\Application(
  realpath(__DIR__.'/../../laravel/')
);
  • Go to Bootstrap/autoload.php file and change 转到Bootstrap / autoload.php文件并进行更改

    require DIR .'/../vendor/autoload.php'; 要求DIR 。'/ .. / vendor / autoload.php';

to

require __DIR__.'/../../laravel/vendor/autoload.php';  

It should work now. 它现在应该工作。
(PS I don't like this markdown typing. it shows some of my codes in block but does not some of them) (PS我不喜欢这种降价打字。它显示了我的一些代码,但没有一些代码)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM