![]() |
|
Guide How to Deploy Laravel on CyberPanel (OpenLiteSpeed): Tested Step by Step - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: CyberPanel (https://adminsforum.com/Forum-cyberpanel) +---- Forum: CyberPanel Guides & Tutorials (https://adminsforum.com/Forum-cyberpanel-guides-tutorials) +----- Forum: CyberPanel Websites & OpenLiteSpeed Guides (https://adminsforum.com/Forum-cyberpanel-websites-openlitespeed-guides) +----- Thread: Guide How to Deploy Laravel on CyberPanel (OpenLiteSpeed): Tested Step by Step (/Thread-guide-how-to-deploy-laravel-on-cyberpanel-openlitespeed-tested-step-by-step) |
How to Deploy Laravel on CyberPanel (OpenLiteSpeed): Tested Step by Step - JAY - 10-26-2026 How to Deploy Laravel on CyberPanel (OpenLiteSpeed): Tested Step by Step Laravel runs fine on CyberPanel's OpenLiteSpeed, and the Code: .htaccessCode: public/Code: laravel.cyber.adminslab.comWhat you need
Step 1: Create the project as the site user Never run Composer as root for a website. Files would belong to root and PHP couldn't write to Code: storage/Code: public_htmlCode: cd /home/cyber.adminslab.com
sudo -u cyber2602 -H composer create-project laravel/laravel laravel --no-interactionCode: composerThe installer ended with the first migrations ( Code: create_users_tableCode: create_cache_tableCode: create_jobs_tableCode: cd laravel
sudo -u cyber2602 php artisan --versionStep 2: Add the domain with the right document root Then add the domain in Websites > Create Sub/Addon Domain, with the document root pointing at Laravel's Code: public
Why public/? Everything above Code: public/Code: .envCode: storage/Code: vendor/Step 3: Remove CyberPanel's index.html CyberPanel drops its "CyberPanel Installed" page into every new document root. In our Code: laravel/publicCode: index.htmlCode: index.phpCode: drwxr-x---Code: cyber2602Code: nogroupCode: /Code: rm /home/cyber.adminslab.com/laravel/public/index.htmlStep 4: Switch .env to production A fresh Laravel project ships with development settings. This is what Code: .envCode: APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:8000
DB_CONNECTION=sqliteCode: APP_DEBUG=trueCode: cd /home/cyber.adminslab.com/laravel
sed -i 's/^APP_ENV=.*/APP_ENV=production/; s/^APP_DEBUG=.*/APP_DEBUG=false/' .env
sed -i 's|^APP_URL=.*|APP_URL=https://laravel.cyber.adminslab.com|' .env
sudo -u cyber2602 php artisan optimizeCode: optimizeCode: .envStep 5: Check it After switching to production and caching, every check passed: Code: U=https://laravel.cyber.adminslab.com
for p in / /up /nope /.env; do curl -s -o /dev/null -w "$p %{http_code}\n" $U$p; done
Step 6: The scheduler If your app uses Laravel's task scheduler, it needs one cron job that runs every minute. You can add it in the panel (cron jobs in CyberPanel) or from SSH as root: Code: L='* * * * * cd /home/cyber.adminslab.com/laravel && /usr/local/lsws/lsphp83/bin/php artisan schedule:run >/dev/null 2>&1'
(crontab -u cyber2602 -l; echo "$L") | crontab -u cyber2602 -
crontab -u cyber2602 -lUsing MySQL instead of SQLite We stayed on SQLite for this test. For MySQL/MariaDB, create a database and user in CyberPanel (databases in CyberPanel), then set in Code: .envCode: DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=yoursite_db
DB_USERNAME=yoursite_user
DB_PASSWORD=the-password-you-setCode: sudo -u SITEUSER php artisan migrate --forceCode: php artisan optimizeCommon problems
More CyberPanel guides
Tested on CyberPanel 3.0 (build 8, OpenLiteSpeed edition) on Ubuntu 24.04, October 2026. Menu names can change slightly between versions. |