[英]laravel 5.2 internal server error
My laravel project work good in localhost by artisan serve
commend. 我的laravel项目在
artisan serve
在localhost工作良好,值得推荐。 Now i'm trying to host it on web host. 现在,我正在尝试将其托管在虚拟主机上。 I upload my project under
public_html
and copy all files from public
folder i also edit app.php
'debug' => env('APP_DEBUG', true),
for showing the error. 我上传我的项目下
public_html
复制所有文件public
文件夹我还编辑app.php
'debug' => env('APP_DEBUG', true),
用于显示错误。
i edit index.php 我编辑index.php
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
but it still give a 500 Internal server error back. 但它仍会返回500 Internal server error。
I also try an another way, Upload my project into root directory except public
folder and upload public
folder into public_html
directory . 我也尝试了另一种方式,上传我的项目到根目录以外
public
文件夹和上传public
文件夹到public_html
目录。 and i edit index.php
as 我将
index.php
编辑为
require __DIR__.'/laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/laravel/bootstrap/app.php';
i can't find what wrong with my code. 我找不到我的代码有什么问题。 how can i deploy my laravel 5.2 project into a web hosting.?
我如何将laravel 5.2项目部署到虚拟主机中?
No No no.. You need to achieve the second option with some improvements. 否否否。您需要对第二个选项进行一些改进。 Let me explain it to you.
让我向您解释。 A laravel application looks like:
laravel应用程序如下所示:
app/
config/
public/
public/index.php
.env
composer.json
artisan
Right? 对? good, now a web host's structure looks like:
很好,现在虚拟主机的结构如下:
/home/user/
/home/user/public_html/
But the structure above does not fit our needs because is public/
folder that should be accessed instead of public_html/
. 但是上面的结构不符合我们的需求,因为应该访问的是
public/
文件夹而不是public_html/
。 So.. the first step is to upload your project, lets say, like these: 所以..第一步是上传您的项目,就像这样:
/home/user/home/project/app/
/home/user/project/config/
/home/user/project/.env
/home/user/project/composer.json
/home/user/project/public/index.php
The next step is decide if you want your project as a main domain, or as subdomain. 下一步是确定要将项目作为主要域还是子域。
If your laravel's project will serve as a main domain just edit apache's config file httpd.conf
and set the following rules: 如果您的laravel项目将用作主域,则只需编辑apache的配置文件
httpd.conf
并设置以下规则:
DocumentRoot "/home/user/project/public" ... DocumentRoot“ / home / user / project / public” ...
If you want you project as a subdomain, just edit the apache's config file httpd.conf
and add a virtual server like this: 如果要作为子域进行项目开发,只需编辑apache的配置文件
httpd.conf
并添加一个虚拟服务器,如下所示:
Listen 80 <VirtualHost *:80> DocumentRoot "/home/user//project/public" ServerName my-project.example.com # Other directives here </VirtualHost>
With this directive you are telling to apache Hey! when people visits my-project.example.com show them the content of my site under /home/user/site/public
使用此指令,您要告诉apache
Hey! when people visits my-project.example.com show them the content of my site under /home/user/site/public
Hey! when people visits my-project.example.com show them the content of my site under /home/user/site/public
. Hey! when people visits my-project.example.com show them the content of my site under /home/user/site/public
。
IF you are using cpanel, just create a subdomain and point it to
/home/user/site/public
如果您使用的是cpanel,则只需创建一个子域并将其指向
/home/user/site/public
That is all, you do not need to hack any project's files like index.php, that is a bad practice. 就是这样,您不需要黑客入侵任何项目的文件,例如index.php,这是一个坏习惯。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.