Deploy Laravel 11 Project to Hostinger Business Web Hosting Plan
Prakash Nayak
Posted on May 8, 2024
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.
Get SSH access from the Hostinger dashboard.
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).
Go to your desired domain directory root using command cd directory/
.
To go back from directory use command cd ..
- 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
In Bash Terminal to your root directory of domain/sub domain
git clone your-project-repository-url .
- 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
- 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.
- 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
- 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
- Done Completed
Posted on May 8, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.