How to deploy a Laravel 12 project on Hostinger with Tailwind CSS and an admin panel
Deploying a Laravel 12 project on Hostinger, complete with Tailwind CSS and a custom admin panel, is a great way to bring together modern design and robust backend functionality. If your goal is to get your app up and running in a production environment with minimal friction, this guide has you covered. Before you dive in, make sure your project is pushed to a public GitHub repository.
Getting started with SSH access and server preparation
Begin by connecting to your Hostinger server via SSH. Once you’re in, install Composer to manage your PHP dependencies. Run the following commands one by one to set it up:
php -r “copy(‘https://getcomposer.org/installer’, ‘composer-setup.php’);”
php -r “if (hash_file(‘sha384’, ‘composer-setup.php’) === ‘dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”
php composer-setup.php
php -r “unlink(‘composer-setup.php’);”
mv composer.phar ~/
Next, install Node.js and NPM using NVM, which will give you better control over the Node version you’re using:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
echo ‘export NVM_DIR=”$HOME/.nvm”‘ >> ~/.profile
echo ‘[ -s “$NVM_DIR/nvm.sh” ] && \. “$NVM_DIR/nvm.sh”‘ >> ~/.profile
echo ‘[ -s “$NVM_DIR/bash_completion” ] && \. “$NVM_DIR/bash_completion”‘ >> ~/.profile
source ~/.profile
nvm install node
Cloning the project and setting up the environment
Navigate to your domain folder, for example:
cd domains
cd yourdomain.com
Clone your repository and move the files into your admin panel directory:
git clone https://github.com/yourusername/laravelproject.git
mv laravelproject/* admin/
Now install the PHP dependencies using Composer:
php ~/composer.phar install
And install your JavaScript dependencies, then build your assets:
npm install
npm run build
Final configuration and deployment tasks
Set up your environment file:
cp .env.example .env
Generate your application key:
php artisan key:generate –ansi
Create a symbolic link for the storage directory:
php artisan storage:link
Edit your .htaccess file to redirect all traffic to the public directory:
nano .htaccess
Then add the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Save and exit.
Link the public directory to the web root:
ln -s public public_html
Now configure your .env file with your database credentials:
vim .env
Update the following:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_password
Finally, run your migrations and seed your database:
php artisan migrate
php artisan db:seed
And that’s it! Your Laravel 12 application is now deployed on Hostinger, styled with Tailwind CSS, and ready to serve with a fully functional admin panel.