Laravel Deployment on Shared Hosting - 404 Error

喜夏-厌秋 提交于 2020-01-23 17:29:45

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/34630868/laravel-deployment-on-shared-hosting-404-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!