共享主机上的Laravel部署 - 404错误 [英] Laravel Deployment on Shared Hosting - 404 Error

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

问题描述

我正在尝试在共享主机cpanel上部署我的laravel 5.1应用程序。但是我收到404错误。


404



找不到



在此服务器上无法找到请求的资源!


上传项目我做了项目目录的克隆,并通过它们的FileManger将其上传到cpanel上。然后将公用文件夹项移动到Public_Html。



我的.htaccess文件内容如下所示:

  IfModule mod_rewrite.c> 
< IfModule mod_negotiation.c>
选项--MultiViews
< / IfModule>

RewriteEngine On
RewriteBase /

#重定向跟踪斜杠...
RewriteRule ^(。*)/ $ / $ 1 [L,R = 301]

#处理前端控制器
RewriteCond%{REQUEST_FILENAME}!-d
RewriteCond%{REQUEST_FILENAME}!-f
RewriteRule ^ index.php [L]
< / IfModule>

我还更改了index.php中的以下行:

  require __DIR __。'/ .. / bootstrap / autoload.php'; 
$ app = require_once __DIR __。'/ .. / bootstrap / app.php';

  require __DIR __。'/ .. / objecsys / bootstrap / autoload.php'; 
$ app = require_once __DIR __。'/ .. / objecsys / bootstrap / app.php';

这种部署方法可能是错误的?

解决方案

在cPanel中部署Laravel应用程序非常简单(如果要在附加域上部署)。



在cPanel中,继续添加域,然后创建一个新的附加域。



默认情况下,cPanel以这种方式为您生成文档根目录:

  public_html / mydomain.com 

将其更改为:

  public_html / mydomain.com / MyLaravelApp / public 

现在将您的Laravel项目上传到 public_html / mydomain.com 目录下。



应该是这样的。 p>



如果您已经有一个附加域。单击修改附加域(仅在下面创建Addon域)



单击文档根列中的编辑图标,然后更改域的文档根。




I am trying to deploy my laravel 5.1 application on shared hosting cpanel. But I am getting 404 error.

404

Not Found

The resource requested could not be found on this server!

To upload the project, I make a clone of project directory and uploaded it on cpanel via their FileManger. Then move the Public folder items into Public_Html.

My .htaccess file content is shown below:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
       RewriteBase /

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

I also changed the following lines in index.php:

require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';

to

require __DIR__.'/../objecsys/bootstrap/autoload.php';
$app = require_once __DIR__.'/../objecsys/bootstrap/app.php';

What could be wrong with this deployment approach?

解决方案

Deploying Laravel app in cPanel is quite simple(if you are deploying on add-on domain).

In cPanel, go on add-on domains and then create a new add-on domain.

By default cPanel generates document root for you in this manner:

public_html/mydomain.com

Change it to:

public_html/mydomain.com/MyLaravelApp/public

Now upload your Laravel project under public_html/mydomain.com directory.

It should look like this.

If you have already an add-on domain. Go to Modify add-on domain (just below Create an Addon Domain)

Click edit icon in document root column and change your domain's document root.

这篇关于共享主机上的Laravel部署 - 404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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