Deploy Lekhya on Hostinger

Complete step-by-step guide to host Lekhya on Hostinger VPS or Shared Hosting.

Recommended: Hostinger VPS

For Lekhya ERP, use Hostinger VPS KVM2 or higher (2 vCPU, 8GB RAM). This gives you PHP 8.4, MySQL 8.0, Redis, and root access needed for queue workers. Shared hosting works for basic use but can't run queue workers.

Option A — Hostinger VPS (Recommended)

1

Get VPS + Set Up Server

# Order Hostinger KVM VPS (Ubuntu 22.04)

# Connect via SSH

ssh root@your-vps-ip

 

# Update system

apt update && apt upgrade -y

 

# Install required packages

apt install -y nginx php8.4-fpm php8.4-mysql php8.4-redis

apt install -y php8.4-xml php8.4-mbstring php8.4-curl php8.4-zip

apt install -y php8.4-gd php8.4-bcmath php8.4-intl

apt install -y mysql-server redis-server git unzip

 

# Install Composer

curl -sS https://getcomposer.org/installer | php

mv composer.phar /usr/local/bin/composer

2

Set Up MySQL Database

mysql -u root -p

 

-- Inside MySQL:

CREATE DATABASE lekhya CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

CREATE USER "lekhya_user"@"localhost" IDENTIFIED BY "StrongPassword123!";

GRANT ALL PRIVILEGES ON lekhya.* TO "lekhya_user"@"localhost";

FLUSH PRIVILEGES;

EXIT;

3

Clone & Configure Lekhya

cd /var/www

git clone https://github.com/prabhassaas/lekhya.git

cd lekhya/lekhya-app

 

# Install PHP dependencies

COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev --optimize-autoloader

 

# Set up environment

cp .env.example .env

php artisan key:generate

 

# Edit .env with your settings:

nano .env

 

# Key settings to change:

APP_ENV=production

APP_URL=https://yourdomain.com

DB_HOST=127.0.0.1

DB_DATABASE=lekhya

DB_USERNAME=lekhya_user

DB_PASSWORD=StrongPassword123!

CACHE_DRIVER=redis

SESSION_DRIVER=redis

QUEUE_CONNECTION=redis

4

Run Migrations & Seed

cd /var/www/lekhya/lekhya-app

 

# Run database migrations

php artisan migrate --force

 

# Seed GST HSN codes and plan data

php artisan db:seed --class=HsnSacSeeder --force

php artisan db:seed --class=PlanSeeder --force

php artisan db:seed --class=PermissionSeeder --force

 

# Set up storage

php artisan storage:link

chown -R www-data:www-data storage bootstrap/cache

chmod -R 775 storage bootstrap/cache

 

# Optimize for production

php artisan config:cache

php artisan route:cache

php artisan view:cache

5

Configure Nginx

nano /etc/nginx/sites-available/lekhya

 

# Paste this config:

server {

listen 80;

server_name yourdomain.com www.yourdomain.com;

root /var/www/lekhya/lekhya-app/public;

index index.php;

 

location / {

try_files $uri $uri/ /index.php?$query_string;

}

 

location ~ \.php$ {

fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

include fastcgi_params;

}

}

 

# Enable site

ln -s /etc/nginx/sites-available/lekhya /etc/nginx/sites-enabled/

nginx -t && systemctl reload nginx

6

SSL (HTTPS) with Let's Encrypt

apt install -y certbot python3-certbot-nginx

certbot --nginx -d yourdomain.com -d www.yourdomain.com

 

# Auto-renewal

crontab -e

# Add: 0 3 * * * certbot renew --quiet

7

Set Up Queue Workers (for AI + Connector jobs)

# Create supervisor config for queue worker

apt install -y supervisor

 

nano /etc/supervisor/conf.d/lekhya-queue.conf

 

# Paste:

[program:lekhya-queue]

process_name=%(program_name)s_%(process_num)02d

command=php /var/www/lekhya/lekhya-app/artisan queue:work redis --sleep=3 --tries=3 --max-time=3600

directory=/var/www/lekhya/lekhya-app

user=www-data

numprocs=2

autostart=true

autorestart=true

stopwaitsecs=3600

stderr_logfile=/var/log/lekhya-queue.err.log

stdout_logfile=/var/log/lekhya-queue.out.log

 

# Start

supervisorctl reread && supervisorctl update && supervisorctl start lekhya-queue:*

8

Set Up Cron (for scheduled tasks)

crontab -e -u www-data

 

# Add:

* * * * * cd /var/www/lekhya/lekhya-app && php artisan schedule:run >> /dev/null 2>&1

Option B — Hostinger Shared Hosting

Limitation: No queue workers. AI extraction and async jobs won't work. OK for basic accounting use.

  1. Go to Hostinger → Hosting → hPanel → File Manager
  2. Upload lekhya-app/ contents to public_html/ (or a subdirectory)
  3. Point domain to public/ folder using .htaccess and custom document root
  4. Create MySQL database via hPanel → Databases
  5. Edit .env via File Manager
  6. Run migrations via hPanel → PHP → Run Script or SSH terminal (if available)
  7. Add cron job via hPanel → Advanced → Cron Jobs

Post-Deployment Checklist

APP_ENV=production and APP_DEBUG=false in .env
HTTPS enabled with valid SSL certificate
Queue workers running (supervisor status)
Cron job added for scheduled tasks
Storage directory writable by www-data
Seed completed: HSN codes, permissions, plans
First admin user created via registration
Backup configured (daily MySQL dump + storage backup)
GST settings configured (GSTIN, GSP credentials or mock mode)