Prerequisites
Before installing Laravel, make sure you have:
- SSH access to your VPS
- PHP 8.0+ installed
- Composer installed
- A domain added in HestiaCP
Step 1: Install Composer
ssh hxroot@YOUR_SERVER_IP -p 22
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
Step 2: Install Laravel
cd /home/admin/web/example.com/public_html
Via Composer create-project:
composer create-project laravel/laravel .
Step 3: Set Permissions
chown -R admin:www-data .
chmod -R 775 storage bootstrap/cache
chmod -R 775 public
Step 4: Configure Environment
cp .env.example .env
php artisan key:generate
Edit .env with your database credentials:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=laravel_user
DB_PASSWORD=your_password
Step 5: Create Database in HestiaCP
Go to HestiaCP → DB → Add Database.
Step 6: Run Migrations
php artisan migrate
Step 7: Configure Web Server for Laravel
In HestiaCP, edit domain → Advanced Options:
- Web Template: Select or create Laravel-friendly template
- Document Root: /public
Or manually edit Nginx/Apache config to point to /public directory.
Step 8: Set Up Queue Worker (Optional)
sudo nano /etc/systemd/system/laravel-queue.service
Add:
[Unit]
Description=Laravel Queue Worker
[Service]
User=admin
Group=www-data
WorkingDirectory=/home/admin/web/example.com/public_html
ExecStart=/usr/bin/php artisan queue:work --sleep=3 --tries=3
Restart=always
[Install]
WantedBy=multi-user.target
Enable and start:
sudo systemctl enable laravel-queue
sudo systemctl start laravel-queue
Step 9: Set Up Cron for Laravel Scheduler
crontab -e
Add:
* * * * * cd /home/admin/web/example.com/public_html && php artisan schedule:run >> /dev/null 2>&1
✅ Laravel has been installed successfully!