Application hosting
Deploy Laravel with PHP, MariaDB, Redis, and Cron Jobs
Deploy Laravel on HostRight with Composer, a private app root, public document root, MariaDB, Redis, SSL, queues, and the Laravel scheduler.
Laravel works well on managed PHP hosting when the application uses a public public directory, a supported PHP version, Composer, a database, and a predictable way to run scheduled commands.
1. Deploy the project privately
Store the project outside the public web directory:
apps/example-laravel/
├── app/
├── bootstrap/
├── config/
├── database/
├── public/
├── resources/
├── routes/
├── storage/
├── composer.json
└── .env
Set the domain document root to apps/example-laravel/public. Never expose .env, storage, Git metadata, or the project root directly.
Deploy with Git or SFTP, then install production dependencies over SSH:
cd ~/apps/example-laravel
composer install --no-dev --optimize-autoloader
php artisan storage:link
2. Select PHP and configure the environment
Use Extra Features → Select PHP version to choose a Laravel-compatible PHP version and enable the extensions required by the application, including ctype, curl, fileinfo, mbstring, openssl, pdo, pdo_mysql, tokenizer, xml, and zip where needed.
Set APP_ENV=production, APP_DEBUG=false, APP_URL, APP_KEY, and the database values in protected environment settings. Generate an application key during initial setup and never publish it.
3. Add MariaDB and Redis
Create the database and user in Account Manager → Databases. Use the exact HostRight database details in the Laravel environment:
DB_CONNECTION=mysql
DB_HOST=HOSTRIGHT_DATABASE_HOST
DB_DATABASE=ACCOUNT_DATABASE
DB_USERNAME=ACCOUNT_DATABASE_USER
DB_PASSWORD=SECRET
Enable Redis under Advanced Features → Redis, copy the Unix socket path, and configure Laravel's cache, session, or queue connection to use it. Use a separate Redis database ID or key prefix for each application.
See create and manage a database and enable and use Redis.
4. Run migrations and cache configuration
After checking the database connection, run:
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
Back up the database before production migrations. Test login, forms, uploads, mail, queues, and static assets after deployment.
5. Schedule Laravel commands
Laravel's scheduler needs one Cron Job that runs every minute. In Advanced Features → Cron Jobs, create a job with the PHP binary and the application's artisan path:
cd /home/ACCOUNT_USERNAME/apps/example-laravel && php artisan schedule:run >> /home/ACCOUNT_USERNAME/logs/laravel-scheduler.log 2>&1
Use the exact account path and PHP command available in your HostRight account. Define the actual schedule in routes/console.php or the framework-supported scheduler file. Read run scheduled tasks with Cron Jobs for the schedule fields and output handling.
Queue workers and long-running daemons may not be suitable for shared hosting. Use a VPS or managed worker service when the application requires persistent background processes.
6. Enable SSL and maintain the application
Request the domain certificate after DNS resolves to HostRight, then set APP_URL to the HTTPS URL and test secure cookies, CSRF protection, redirects, and webhooks.
Keep Laravel, Composer dependencies, PHP, and application packages updated. Take a backup before framework upgrades and review logs after each release.