Complete step-by-step guide to host Lekhya on Hostinger VPS or Shared Hosting.
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.
# 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
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;
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
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
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
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
# 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:*
crontab -e -u www-data
# Add:
* * * * * cd /var/www/lekhya/lekhya-app && php artisan schedule:run >> /dev/null 2>&1
Limitation: No queue workers. AI extraction and async jobs won't work. OK for basic accounting use.