Laravel 5 不适用于共享主机
Laravel 5 is not working on shared hosting
我已经在本地主机上测试了我的 Laravel 5 项目,它与这个 url - http://localhost/project-name/public/
一起工作正常
然后我将我的项目上传到共享主机上,我对 .env 文件上的数据库进行了理想的更改,然后尝试使用 url - http://companysite.com/folder/innerFolder/public/ 访问它
但无法正常工作并出现 500 内部服务器错误
我已经解决了其他相关问题,但没有答案引导我找到解决方案。我已完成以下步骤
- 将我的项目上传到平行于 public_html
的根目录
- 更新为 project/public/index。php
- 尝试创建指向我的项目的子域但没有成功
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
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.
Additionally, a 500 Internal Server Error error was encountered while
trying to use an ErrorDocument to handle the request.
我已经提到了这个 link laravel.io
最后,我在共享主机上完成了这项工作。这就是我所做的
- 在正确配置的本地主机中设置项目Laravel 5
- 仔细检查 PHP 5.4 的服务器配置(这是因为每个
.htaccess 文件的小改动可能会改变该配置)
- 在public_html的同级创建一个目录,并把
该文件夹内的项目。
- 把public(L5)的内容直接放在public_html上(注意
不要意外覆盖 .htaccess 文件)
现在...这是"tricky part"...我看到这个结构
邮件
perl5
php
public_html
[框架文件夹]
SSL
在public_html里面我可以看到Laravel 5的public目录的所有文件
转到 index.php 并编辑第 22
行
From this
require __DIR__.'/../bootstrap/autoload.php';
To this
require __DIR__.'/../[framework-folder]/bootstrap/autoload.php';
第 36 行
From this
$app = require_once __DIR__.'/../bootstrap/app.php';
To this
$app = require_once __DIR__.'/../[framework-folder]/pulcro/bootstrap/app.php';
最后一步是编辑 .htaccess 文件并添加一些行
RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} !^
RewriteRule ^(.*)$ / [L]
并更新 [框架文件夹]/server.php
From this
require_once __DIR__.'/public/index.php';
To this
require_once __DIR__.'/public_html/index.php';
刷新浏览器缓存,然后..胜利!!
我知道这不是安装框架的绝对正确方法(天哪,我从来没有说过 Composer)
但是......它现在对我有用
希望这可以帮助某人部署 Laravel 5
感谢 Neeraj Rathod,但我发现这篇文章更有用,当然也更简单!
WHY AM I GETTING A 500 INTERNAL SERVER ERROR MESSAGE?
就我而言,通过阅读那篇文章,我从 "error pages" 中发现不得为 "public" 文件夹中的 "index.php" 文件设置 "group writable" 权限,并且也适用于通过路由的所有文件夹。您还必须检查您的共享主机 php 版本是否高于 7.0
Neeraj Rathod 所说的一切,也去你的项目 vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php
在第 1337 行中,您可以在 addWhereExistsQuery
方法中找到以下代码
$this->wheres[] = compact('type', 'operator', 'query', 'boolean');
您只需删除 'operator'
参数。
多亏了这个link:
现在我的 laravel 测试项目博客上线了。
我已经在本地主机上测试了我的 Laravel 5 项目,它与这个 url - http://localhost/project-name/public/
一起工作正常然后我将我的项目上传到共享主机上,我对 .env 文件上的数据库进行了理想的更改,然后尝试使用 url - http://companysite.com/folder/innerFolder/public/ 访问它
但无法正常工作并出现 500 内部服务器错误
我已经解决了其他相关问题,但没有答案引导我找到解决方案。我已完成以下步骤
- 将我的项目上传到平行于 public_html 的根目录
- 更新为 project/public/index。php
- 尝试创建指向我的项目的子域但没有成功
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
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.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
我已经提到了这个 link laravel.io
最后,我在共享主机上完成了这项工作。这就是我所做的
- 在正确配置的本地主机中设置项目Laravel 5
- 仔细检查 PHP 5.4 的服务器配置(这是因为每个 .htaccess 文件的小改动可能会改变该配置)
- 在public_html的同级创建一个目录,并把 该文件夹内的项目。
- 把public(L5)的内容直接放在public_html上(注意 不要意外覆盖 .htaccess 文件)
现在...这是"tricky part"...我看到这个结构
邮件
perl5
php
public_html
[框架文件夹]
SSL
在public_html里面我可以看到Laravel 5的public目录的所有文件 转到 index.php 并编辑第 22
行From this require __DIR__.'/../bootstrap/autoload.php';
To this require __DIR__.'/../[framework-folder]/bootstrap/autoload.php';
第 36 行
From this $app = require_once __DIR__.'/../bootstrap/app.php';
To this $app = require_once __DIR__.'/../[framework-folder]/pulcro/bootstrap/app.php';
最后一步是编辑 .htaccess 文件并添加一些行
RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} !^
RewriteRule ^(.*)$ / [L]
并更新 [框架文件夹]/server.php
From this require_once __DIR__.'/public/index.php';
To this require_once __DIR__.'/public_html/index.php';
刷新浏览器缓存,然后..胜利!! 我知道这不是安装框架的绝对正确方法(天哪,我从来没有说过 Composer) 但是......它现在对我有用 希望这可以帮助某人部署 Laravel 5
感谢 Neeraj Rathod,但我发现这篇文章更有用,当然也更简单!
WHY AM I GETTING A 500 INTERNAL SERVER ERROR MESSAGE?
就我而言,通过阅读那篇文章,我从 "error pages" 中发现不得为 "public" 文件夹中的 "index.php" 文件设置 "group writable" 权限,并且也适用于通过路由的所有文件夹。您还必须检查您的共享主机 php 版本是否高于 7.0
Neeraj Rathod 所说的一切,也去你的项目 vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php
在第 1337 行中,您可以在 addWhereExistsQuery
方法中找到以下代码
$this->wheres[] = compact('type', 'operator', 'query', 'boolean');
您只需删除 'operator'
参数。
多亏了这个link: