How to deploy laravel project in 000webhost

Servers are expensive. Many professionals buy but some prefer to use free servers for testing purpose. In this tutorial, we will deploy our project in 000webhost. First of all, we need to create a free account in 000webhost. After creating an account, log in to your dashboard to get started.

Upload files to server

First of all, we need to upload our laravel application files to the 000webhost server. For this click on the File Manager and we will be directed to the root directory where we need to upload our application files. Since, there are hundreds of files, zipping the project into a single file makes it fast and easy. So, let’s zip our project and upload into /public_html directory.
How to deploy laravel project in 000webhost

Extract project

After file upload is completed, we need to extract the files. You can give . in destination folder while extracting. It will extract in the current folder. After extracting, we need to move our files to the root directory. To do this, click on mark all checkbox and click move button on top. It will prompt a box where we choose the directory to move our files. Make sure you select root folder (/).
How to deploy laravel project in 000webhost

Setting Up

Now it’s time to setup our project. We can now remove the public_html directory. Rename our laravel application public folder to public_html. After this change, we need to register our folder in AppServiceProvider.

Open you App/Providers/AppServiceProvider.php and change the code inside register method as below:
How to deploy laravel project in 000webhost

$this -> app -> bind('path.public', function()
        return base_path('public_html');

Environment Setup

Find the .env file in the root directory. Right click on it and click edit. Search for APP_KEY and copy key after base64:.
How to deploy laravel project in 000webhost

Now, open config/app.php file and add the key as like below:

'key' => env('APP_KEY', base64_decode('gbcuWFSOB2cQPWGVA1xpEVb5SDUwG7EPjcgkuuQdRso=')),

Database Setup

We also need a database. For this, click on Create Database. Fill the required credentials.
How to deploy laravel project in 000webhost

Clear Cache

Finally in last step, we need to clear cache from the application. For this, go to bootstrap/cache/ and clear all files except .gitignore file.

After all these setups, when we navigate to our domain, we can our system.
How to deploy laravel project in 000webhost

These are the required steps for uploading your laravel application in 000webhost. If you find any difficulty accessing your web page, you can enable the debug mode to true and trace the error.

Read More Articles



Please enter your comment!
Please enter your name here