Deploying a Laravel application over SSH, step by step
Deploying a Laravel application
This guide describes a manual Laravel deployment over SSH. If browser-only deployment without your own SSH client is enough for you, see the Deployments tab and Quick actions – cloning, pulling and common artisan commands can all be done directly in the panel.
Prerequisites
- A hosting with SSH access enabled
- A Git repository with the Laravel application (public, or private with a deploy key added)
- A database created in Database management in the panel
Step 1: Connect via SSH
Your login credentials and a ready-to-use connect command are in the panel, on the hosting's Services tab, in the SSH Access panel (username, password, host and port).
ssh your_user@host -p PORT
Step 2: Add a deploy key (private repository)
If the repository is private, generate a deploy key on the Deployments tab (Development → Deployments → Deploy key) and add it as a deploy key on the repository. A public repository does not need this step.
Step 3: Clone the repository
cd /var/www/html
git clone git@github.com:your-account/your-project.git .
Step 4: Install PHP dependencies
composer install --optimize-autoloader --no-dev
Step 5: Install JavaScript dependencies and build the frontend
npm install
npm run build
Step 6: Configure .env
cp .env.example .env
Copy the database credentials directly from the panel: hosting → Services tab → MySQL Access → the "Laravel .env (internal)" block has a button that copies the whole block. The internal host (the Host field under "Internal Connection") is usually mysql, not localhost – the application and the web server share the same environment, but the database runs separately on the same network.
APP_ENV=production
APP_DEBUG=false
APP_URL=https://your-domain.sk
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_database_user
DB_PASSWORD=your_password
Step 7: Generate the application key
php artisan key:generate
Step 8: Run migrations
php artisan migrate --force
Step 9: Create the storage symlink
php artisan storage:link
Step 10: Optimize for production
php artisan config:cache
php artisan route:cache
php artisan view:cache
Step 11: Fix permissions
fix_permissions
See Fixing file permissions for details on this command.
Updating the application
For subsequent deployments, repeat only the relevant steps:
cd /var/www/html
git pull origin main
composer install --optimize-autoloader --no-dev
npm install && npm run build
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
fix_storage
Scheduler
If the application uses the Laravel task scheduler, you have two options without needing a server-level cron of your own:
- Development → Cron Jobs: add a job with the command
php artisan schedule:run, the working directory set to the application root (e.g./var/www/html), and the schedule* * * * *(every minute). See Cron Jobs. - Development → Supervisor Tasks: the "Laravel Scheduler" template runs
php artisan schedule:workas a permanently running process that handles the once-a-minute triggering itself – no cron entry needed. See Background processes.
Queue workers
If the application processes jobs through a queue, add the Laravel Queue Worker template (php artisan queue:work --sleep=3 --tries=3) under Development → Supervisor Tasks, or Laravel Horizon if the application uses it. A Supervisor task runs as a persistent process and restarts itself if it crashes. See Background processes.
Was this article helpful?
Your feedback helps us improve our documentation