DEV Community

Prakash Nayak
Prakash Nayak

Posted on • Updated on

Deploy Laravel 11 Project to Hostinger Business Web Hosting Plan

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 -> SSH Access -> Activate the status.

Image description

Get SSH access from the Hostinger dashboard.

Image description

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

Image description

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
Enter fullscreen mode Exit fullscreen mode

Image description

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

git clone your-project-repository-url .

  1. Install Composer Locally:
* Install Composer locally with the following commands in SSH Terminal of your domain directory:
Enter fullscreen mode Exit fullscreen mode
    ```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
    ```
Enter fullscreen mode Exit fullscreen mode
  1. Install Composer Dependencies:
* Inside the project folder, install Composer dependencies in SSH Terminal of your domain directory:
Enter fullscreen mode Exit fullscreen mode
    ```bash
    php composer.phar install
    ```
Enter fullscreen mode Exit fullscreen mode
  1. 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.
Enter fullscreen mode Exit fullscreen mode
  1. Run Database Migrations:
* Run database migrations to create necessary tables in SSH Terminal of your domain directory:
Enter fullscreen mode Exit fullscreen mode
    ```bash
    php artisan migrate
    ```
Enter fullscreen mode Exit fullscreen mode
  1. 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:
Enter fullscreen mode Exit fullscreen mode
    ```bash
    php artisan storage:link
    ```
Enter fullscreen mode Exit fullscreen mode
  1. 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:
Enter fullscreen mode Exit fullscreen mode
    ```apache
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
    </IfModule>
    # END WordPress
    ```
Enter fullscreen mode Exit fullscreen mode
  1. 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.
Enter fullscreen mode Exit fullscreen mode
    ```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
    ```
Enter fullscreen mode Exit fullscreen mode
  1. Done Completed

Top comments (0)