Deploy Laravel 11 Project to Hostinger Business Web Hosting Plan
Published: 2024-05-08 18:36:20

**Create Subdomain or Main Domain Directory**:

Navigate to either the subdomain directory (e.g., `public_html/subdomain/`) or the main domain directory (e.g., `public_html/`) on your server.

Then go to Hostinger Dashboard Advanced Menu -&gt; SSH Access -&gt; Activate the status.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k8thvxfqmq2ne0hjmffe.png)


Get SSH access from the Hostinger dashboard.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ns5xae3auaxf6ug7yrao.png)


As you log in to the SSH key, copy it, go to the **Terminal**, paste the key, and use the **generated password from the SSH details card table** Enter in your **Bash terminal(Windows).**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ljdb56xvb4wt5rp6sjv.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2t552isepcrer2wunhbm.png)



Go to your desired domain directory root using command `cd directory/`.

To go back from directory use command `cd ..`

1. **Clone Project with Git**:
    
    * Use SSH to navigate to the project's root folder within the chosen directory.
        
    * Clone your project from Git to the root project folder:
        
    * Once you get access to your SSH Terminal
        

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pv60p614l47qhf1vluj.png)

In Bash Terminal to your root directory of domain/sub domain

`git clone your-project-repository-url .`

3. **Install Composer Locally**:
    
    * Install Composer locally with the following commands in SSH Terminal of your domain directory:
        
        ```bash
        php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
        php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified. Things look pretty good. Just as Xima. After finishing - call this script again to install vendors...</br></br>'; require_once 'composer-setup.php'; }"
        php composer.phar -v
        ```
        
4. **Install Composer Dependencies**:
    
    * Inside the project folder, install Composer dependencies in SSH Terminal of your domain directory:
        
        ```bash
        php composer.phar install
        ```
        
5. **Build Assets with Vite**:
    
    * Build your assets using Vite in your local project XAMPP/Laragon etc.
        
    * Upload the generated `build` folder to the server at the respective location.
        
6. **Run Database Migrations**:
    
    * Run database migrations to create necessary tables in SSH Terminal of your domain directory:
        
        ```bash
        php artisan migrate
        ```
        
7. **Create Symbolic Link for Storage** in SSH Terminal of your domain directory:
    
    * Create a symbolic link from the `public/storage` directory to the `storage/app/public` directory:
        
        ```bash
        php artisan storage:link
        ```
        
8. **Update .htaccess use hostinger file explorer and goto your root directory of your domain create .htaccess if its not available then enter the code**:
    
    * Update the `.htaccess` file in the root of your domain project with the following rules:
        
        ```apache
        # BEGIN WordPress
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^(.*)$ public/$1 [L]
        </IfModule>
        # END WordPress
        ```
        
9. **Update .env file**:
    
    * **Use Hostinger File Explorer and go to your domain's root directory** Update the `.env` file in the root of your Laravel project with your environment-specific configurations.
        
        ```plaintext
        APP_URL=https://domainurl.com
        .....
        DB_CONNECTION=mysql
        DB_HOST=127.0.0.1
        DB_PORT=3306
        DB_DATABASE=databasenamecreated
        DB_USERNAME=databaseusernamecreated
        DB_PASSWORD=addpasswordcreated
        .....
        ASSET_URL=https://domain.com/public
        ```
10. Done Completed