Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

shared hosting
laravel
communitycreator

How to deploy a Laravel application to cPanel without /public

Chinweuba Elijah Azubuike

Laravel Logo Laravel LogoCpanel Logo

Starting as a Laravel developer was fun and interesting, until it came to deploying it on a Shared Hosting. There was always the issue of placing /public on the link, and that was not professional at all. It denied the entire site the authenticity it needed. This shot will save you the hassle and hold your hand throughout the process. We will break down the process into steps for better understanding.

In this shot, we are making the following assumptions:

  • You know how to upload a Laravel application to cPanel from your local server.

  • You know how to set up your .env file while on the shared hosting.

  • The only thing you will learn is ensuring that your application is accessed, e.g., yoursite.com and not yoursite.com/public.

You only have to follow two steps to deploy a Laravel application to cPanel without /public.

Step 1

Cut the index.php and .htaccess files from the public folder and paste them into the project root.

Step 2

Open and paste the code below in line 24 in index.php, and save.

require__DIR__.'/vendor/autoload.php';

In line 38, add the line below:

$app = require_once__DIR__.'/bootstrap/app.php';

Summary


Deploying a Laravel application to a shared hosting won’t require running the php artisan serve command.

RELATED TAGS

shared hosting
laravel
communitycreator

CONTRIBUTOR

Chinweuba Elijah Azubuike
RELATED COURSES

View all Courses

Keep Exploring