HITENDRA PATEL

LARAVEL PROJECT UPLOAD TO LIVE SERVER

Published 4 years ago 1910 Views
image

We all know that, laravel is run from public folder not from root folder, so this is difficult to configure laravel project to live server.

Don't worry, it will be easy after following below steps


Step 1 : Make a zip file of project

First of all create zip file of your project.

& also don't forget to include hidden files like .env, .htaccess, etc.


Step 2 : Upload zip file on live serve root directory

Upload zip file to root directory of your hosting server.

Remember root directory means not the public_html (ex : /domains/example.com/public_html), root means one step behind of public_html folder (ex : /domains/example.com/)

Extract all files & folder here (ex : /domains/example.com/)


Step 3 : Rename PUBLIC folder

First of all rename or delete current public_html folder of your hosting server

Rename your project existing "public" folder to "public_html"


Step 4 : Change in AppServiceProvider file

Laravel by default consider public path to "public" folder

but now we have changed that to "public_html"

so we have to make minor changes in code

go to below file :

/app/Providers/AppServiceProvider.php

add below code in above file of boot method

class AppServiceProvider extends ServiceProvider {
    public function boot() {
        ...
        $this->app->bind("path.public", function () {
            return base_path() . "/public_html";
        });
    }
}

That's all done now, you can directly run your project by your URL of project.

You can upload your project directly in public_html without doing any changes above mention & point your root directory to public folder of your project but it will be risky to your project by hackers because all your files are listed in public_html folder

So if possible then ignore this step & follow above step mention in this blog

NOTE : PLEASE CONFIRM THAT YOU HAVE ROOT DIRECTORY ACCESS FROM YOUR HOSTING SERVICE PROVIDER

A BLOG ABOUT DEVELOPMENT

Subscribe and get my latest blog post in your inbox.
image
DIGITAL OCEAN SETUP LARAVEL

Install & configure laravel project into live digital ocean server.

image
LARAVEL PUSH NOTIFICATION

Laravel push notification for devices with FCM

image
INSTALL COMPOSER ON MACOS

Install Composer on MacOS