Code & Data Intermediate

How to Deploy a Laravel Application on Hostinger (Step-by-Step Guide)

Learn how to deploy a Laravel application on Hostinger with this complete step-by-step guide. This tutorial covers uploading your Laravel project, exporting and importing the MySQL database, configuring the .env file, updating the root and public/.htaccess files, and making your Laravel website live. Perfect for beginners using Laravel 10, Laravel 11, or Laravel 12 on Hostinger shared hosting.

A
Afnan Tariq Author
Jul 02, 2026 10 min read 49 views
How to Deploy a Laravel Application on Hostinger (Step-by-Step Guide)
Watch the Tutorial Video

Deploying a Laravel application to a live server may seem difficult if you're doing it for the first time. In this guide, we'll walk through the complete deployment process on Hostinger, from preparing your project locally to making your website live.

By the end of this tutorial, your Laravel application will be running successfully on your Hostinger hosting account.


Prerequisites

Before you begin, make sure you have:

  • A Laravel project running locally

  • A Hostinger hosting account

  • Access to Hostinger File Manager

  • A MySQL database backup

  • Your domain connected to Hostinger


Step 1: Zip Your Laravel Project

Navigate to your Laravel project folder and compress it into a ZIP file.

Example:

my-laravel-project.zip

We'll upload this ZIP file to Hostinger in the next step.


Step 2: Export Your MySQL Database

Open phpMyAdmin (or any database management tool) on your local machine.

  1. Select your Laravel database.

  2. Click Export.

  3. Choose Quick export.

  4. Select SQL format.

  5. Click Go to download the SQL file.

Example:

database.sql

Step 3: Upload Your Laravel Project to Hostinger

Login to your Hostinger account.

Navigate to:

Hosting
→ Manage
→ File Manager

Open the following directory:

public_html

Upload your Laravel ZIP file.

Once the upload completes:

  • Right-click the ZIP file.

  • Click Extract.

  • Extract it inside the public_html directory.

Your folder structure should now look something like this:

public_html/
│
├── app/
├── bootstrap/
├── config/
├── database/
├── public/
├── resources/
├── routes/
├── storage/
├── vendor/
├── artisan
└── .env

Step 4: Create a MySQL Database

From your Hostinger dashboard, go to:

Databases
→ MySQL Databases

Create a new database by providing:

  • Database Name

  • Database Username

  • Database Password

After creating the database, import your previously exported SQL file.

Keep the following information ready:

Database Name
Database Username
Database Password
Database Host

Step 5: Update Your .env File

Open your Laravel project's .env file and update the database credentials.

APP_NAME=Laravel
APP_ENV=production
APP_KEY=YOUR_APP_KEY
APP_DEBUG=false

APP_URL=https://yourdomain.com

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password

Important: Replace APP_URL with your actual domain name.

Example:

APP_URL=https://unitycodinghub.com

Step 6: Configure the Root .htaccess

If the .htaccess file does not exist in the project root, create it.

Replace its contents with:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ public/$1 [L,QSA]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

This redirects all incoming requests to Laravel's public directory.


Step 7: Configure public/.htaccess

Open the following file:

public/.htaccess

If it doesn't exist, create it.

Replace it with the following code:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes +FollowSymLinks
    </IfModule>

    RewriteEngine On

    # Allow direct access to storage files
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^storage/ - [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Handle X-XSRF-Token Header
    RewriteCond %{HTTP:x-xsrf-token} .
    RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]

    # Redirect Trailing Slashes If Not A Folder
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Allow direct access to storage files
    RewriteCond %{REQUEST_URI} ^/storage/
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [L]

    # Laravel Front Controller
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

# Increase PHP upload limits
<IfModule mod_php.c>
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 300
    php_value max_input_time 300
    php_value memory_limit 256M
</IfModule>

This configuration enables Laravel routing, allows access to storage files, and increases PHP upload limits.


Step 8: Verify Your Project Structure

After deployment, your project should look like this:

public_html/
│
├── app/
├── bootstrap/
├── config/
├── database/
├── public/
├── resources/
├── routes/
├── storage/
├── vendor/
├── artisan
├── .env
├── .htaccess

Step 9: Visit Your Website

Open your browser and visit your domain.

Example:

https://yourdomain.com

If everything has been configured correctly, your Laravel application should now be live.


Common Issues

404 Not Found

  • Check both .htaccess files.

  • Make sure mod_rewrite is enabled.

  • Verify that the project was extracted correctly.


Database Connection Error

Double-check the following values in your .env file:

  • DB_DATABASE

  • DB_USERNAME

  • DB_PASSWORD

  • DB_HOST


Storage Images Not Loading

Ensure the storage directory is correctly linked and accessible.


Internal Server Error (500)

Check:

  • File permissions

  • .env configuration

  • Laravel logs inside:

storage/logs/

Conclusion

Congratulations! 🎉 You have successfully deployed your Laravel application on Hostinger.

To recap, you:

  • ✔️ Zipped your local Laravel project

  • ✔️ Exported your MySQL database

  • ✔️ Uploaded and extracted the project in public_html

  • ✔️ Created a new MySQL database

  • ✔️ Updated the .env file with the correct credentials

  • ✔️ Configured the root .htaccess

  • ✔️ Configured the public/.htaccess

  • ✔️ Updated the APP_URL to your domain

  • ✔️ Launched your Laravel application successfully

Your Laravel project is now live and accessible from anywhere in the world!


This format is SEO-friendly, easy to read, and ideal for publishing as a technical blog on your website.

A
Afnan Tariq
Full Stack Developer & Instructor at Unity Coding. Teaching Laravel, React, and modern web development.
ESC

Start typing to search across all content...