Laravel 5无法在共享主机上工作 [英] Laravel 5 is not working on shared hosting

查看:84
本文介绍了Laravel 5无法在共享主机上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在本地主机上测试了我的Laravel 5项目,使用此URL可以正常工作-http://localhost/project-name/public/

I have tested my Laravel 5 project on localhost its working fine with this url - http://localhost/project-name/public/

然后我将项目上传到共享主机上,我对.env文件上的数据库进行了所需的更改,然后尝试使用url访问它-http://companysite.com/folder/innerFolder/public/

Then I uploaded my project on shared hosting, I have made desirable changes for database on .env file then trying to access it with the url - http://companysite.com/folder/innerFolder/public/

但无法正常工作,并出现500个内部服务器错误

but not working and getting 500 internal server error

我已经解决了与相关的其他问题,但没有答案引导我找到解决方案.我已经完成了以下步骤

I have gone through with other questions with the related but no answer lead me to my solution. I have done following steps

  • 在与public_html平行的根目录上上传我的项目
  • 更新到project/public/index.php
  • 尝试创建指向我的项目的子域,但未成功

内部服务器错误

Internal Server Error

服务器遇到内部错误或配置错误,并且 无法完成您的请求.

The server encountered an internal error or misconfiguration and was unable to complete your request.

请通过以下方式与服务器管理员联系: webmaster@techphant.techphant.com通知他们这个时间 错误发生,以及您在此错误之前执行的操作.

Please contact the server administrator at webmaster@techphant.techphant.com to inform them of the time this error occurred, and the actions you performed just before this error.

有关此错误的更多信息可能在服务器错误中可用 日志.

More information about this error may be available in the server error log.

此外,在执行以下操作时遇到了500 Internal Server Error错误 尝试使用ErrorDocument处理请求.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

推荐答案

我已引用此链接最后,我在共享主机上完成了这项工作.这就是我所做的

Finally, I did the job on my shared hosting. This is what I did

  1. 在已正确配置的localhost中设置项目Laravel 5
  2. 再次检查PHP 5.4的服务器配置(这是因为 .htaccess文件上的少许更改可能会更改该配置)
  3. 在public_html的同一级别中创建目录,然后将 项目在该文件夹中.
  4. 直接在public_html上放置public(L5)的内容(请注意 不要意外覆盖.htaccess文件)
  1. Setup a project Laravel 5 in localhost correctly configured
  2. Double check the server configuration of PHP 5.4 (this because every little change on .htaccess file may change that config)
  3. Create a directory in the same level of public_html and put the project inside of that folder.
  4. Put the content of public (L5) directly on public_html (be aware of don't overwrite the .htaccess file accidentally)

现在...这是棘手的部分" ...我看到了这种结构

Now... This is the "tricky part"... I see this structure

邮件

perl5

php

public_html

public_html

[框架文件夹]

ssl

在public_html里面,我可以看到Laravel 5的public目录中的所有文件. 转到index.php并编辑第22行

Inside of public_html I can see all the files of public directory of Laravel 5 Go to index.php and edit the line 22

从这里 需要__DIR __.'/../bootstrap/autoload.php';
对此 需要__DIR __.'/../[framework-folder]/bootstrap/autoload.php';

From this require __DIR__.'/../bootstrap/autoload.php';
To this require __DIR__.'/../[framework-folder]/bootstrap/autoload.php';

第36行

从这里 $ app = require_once __DIR __.'/../bootstrap/app.php';
对此 $ app = require_once __DIR __.'/../[framework-folder]/pulcro/bootstrap/app.php';

From this $app = require_once __DIR__.'/../bootstrap/app.php';
To this $app = require_once __DIR__.'/../[framework-folder]/pulcro/bootstrap/app.php';

最后一步是编辑.htaccess文件并添加一些行

The final step is to edit the .htaccess file and add some lines

RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} !^
RewriteRule ^(.*)$ /$1 [L]

并更新[framework-folder]/server.php

and update [framework-folder]/server.php

从这里 require_once __DIR __.'/public/index.php';
对此 require_once __DIR __.'/public_html/index.php';

From this require_once __DIR__.'/public/index.php';
To this require_once __DIR__.'/public_html/index.php';

刷新浏览器的缓存,然后..胜利!! 我知道这不是绝对正确的安装框架的方式(上帝,我从没谈论过Composer) 但是...现在对我有用 希望这可以对部署Laravel 5的人有所帮助

Refresh the cache of my browser and.. Victory!! I know that this is not the absolute right way to install the framework (God, I never spoke about Composer) But... It's working for me now Hope that this can help somebody in order to deploy Laravel 5

这篇关于Laravel 5无法在共享主机上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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