Archives
Categories
Laravel

Deploying Laravel 5.7 on shared hosting

By on November 28, 2018


Deploying the Laravel in shared hosting is not an easy task for beginners. So here we make it easy to deploy Laravel in a shared hosting environment. Before deploying your local project into the live setting, you need to clean all the cache, routes, config and views made by Laravel in the local machine, i.e. your localhost.

Run the following command on Terminal.

php artisan cache:clean
php artisan view:clear
php artisan config:clear
php artisan route:clear

In your cPanel first, create a folder outside the public_html folder like this:

After that copy local Laravel project except for public folder and upload the files into the folder “laravel” in our example. Thenafter, copy the public folder files and upload into the public_html folder.

Now it is time to change the path in “public_html/index.php”. “index.php” is the file which tells Laravel where to point the application to start.

require __DIR__.'/../laravel/vendor/autoload.php';

$app = require_once __DIR__.'/../laravel/bootstrap/app.php';

The public_path() helper might probably point to the wrong direction with the directory reconfigured. This should be fixed before proceeding.

// rebind public_path()

$app->bind('path.public', function() {
    return __DIR__;
});

Place above ‘Run The Application’

That’s all for the configuration for Laraval setup in a shared hosting environment. If all process has gone well, the Laravel project should run smoothly.

TAGS
RELATED POSTS