AdminsForum

CyberPanel Websites & OpenLiteSpeed Guides

Guide How to Deploy Laravel on CyberPanel (OpenLiteSpeed): Tested Step by Step

Started by JAY 0 replies 98 views
1JAY
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
#1
How to Deploy Laravel on CyberPanel (OpenLiteSpeed): Tested Step by Step

Laravel runs fine on CyberPanel's OpenLiteSpeed, and the
Code:
.htaccess
that ships with Laravel works as it is. The two things that trip people up are the document root (it must be
Code:
public/
, not the project folder) and the development settings Laravel starts with. We deployed a fresh Laravel 13 app on our test server at
Code:
laravel.cyber.adminslab.com
and checked every step.

What you need
  • A website in CyberPanel (ours is
    Code:
    cyber.adminslab.com
    , Linux user
    Code:
    cyber2602
    ). See creating a website.
  • Composer and git: both were already installed by CyberPanel (
    Code:
    /usr/bin/composer
    , Composer 2.10.3).
  • PHP 8.3 or newer with the usual extensions. On our server mbstring, xml, dom, curl, zip, pdo_mysql, bcmath, fileinfo, tokenizer, openssl, ctype and intl were all loaded. Check yours:
    Code:
    php -m
    .
  • A DNS A record for the new name pointing to your server (ours:
    Code:
    laravel.cyber
    at Cloudflare, DNS only).

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/
. Run it as the site's user, from the site's home folder (one level above
Code:
public_html
):
Code:
cd /home/cyber.adminslab.com sudo -u cyber2602 -H composer create-project laravel/laravel laravel --no-interaction
Run plain
Code:
composer
as root and it stops to ask "Continue as root/super user [yes]?". That prompt is the hint you are about to do it wrong.

The installer ended with the first migrations (
Code:
create_users_table
,
Code:
create_cache_table
,
Code:
create_jobs_table
: DONE). New Laravel projects use SQLite by default, so this works without a database. Check it:
Code:
cd laravel sudo -u cyber2602 php artisan --version
We got Laravel Framework 13.38.0.

Step 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
folder:
[Image: attachment.php?aid=515]
  • Domain Type: Sub Domain (or Addon Domain for a different domain name)
  • Domain Name:
    Code:
    laravel.cyber.adminslab.com
  • Document Root Path:
    Code:
    laravel/public
    (CyberPanel puts
    Code:
    /home/cyber.adminslab.com/
    in front)
  • PHP: the same version you used in Step 1
CyberPanel issued a Let's Encrypt certificate during creation ("Domain successfully created"). On our build the form sometimes cleared the domain fields after we picked the Domain Type; check them again before you click Create Domain. More on the form in our subdomain guide.

Why public/? Everything above
Code:
public/
(
Code:
.env
with your app key and passwords,
Code:
storage/
,
Code:
vendor/
) must not be reachable from the web.

Step 3: Remove CyberPanel's index.html
CyberPanel drops its "CyberPanel Installed" page into every new document root. In our
Code:
laravel/public
folder we found a new
Code:
index.html
next to Laravel's
Code:
index.php
, and the folder permissions had changed to
Code:
drwxr-x---
(owner
Code:
cyber2602
, group
Code:
nogroup
). Laravel still answered on
Code:
/
, but don't leave it to chance:
Code:
rm /home/cyber.adminslab.com/laravel/public/index.html

Step 4: Switch .env to production
A fresh Laravel project ships with development settings. This is what
Code:
.env
had right after install:

Code:
APP_ENV=local APP_DEBUG=true APP_URL=http://localhost:8000 DB_CONNECTION=sqlite
Code:
APP_DEBUG=true
on a live site shows full error pages with file paths and settings to anyone who triggers an error. Fix it:
Code:
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 optimize
Code:
optimize
caches config, events, routes and views. Run it again after every change to
Code:
.env
or after you deploy new code, or the old cached values stay active.

Step 5: Check it
After switching to production and caching, every check passed:
[Image: attachment.php?aid=537]

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
  • Code:
    / 200
    : the welcome page.
  • Code:
    /up 200
    : Laravel's health route. This proves URL rewriting works: OpenLiteSpeed read Laravel's own
    Code:
    public/.htaccess
    , no extra rules needed.
  • Code:
    /nope 404
    : a Laravel 404, not a server error.
  • Code:
    /.env 403
    : blocked (and it's outside the document root anyway).

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 -l
The list now showed our existing WordPress job plus the new Laravel line. Use the full PHP path of the version your site runs.

Using 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:
.env
:
Code:
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-set
and run
Code:
sudo -u SITEUSER php artisan migrate --force
followed by
Code:
php artisan optimize
(as the site user).

Common problems
  • You see the "CyberPanel Installed" page: Step 3, delete
    Code:
    public/index.html
    .
  • You see a directory listing or Laravel's source: the document root is the project folder, not
    Code:
    public/
    .
  • 500 error, "Permission denied" in storage/logs: files were created as root. Fix:
    Code:
    chown -R cyber2602:cyber2602 /home/cyber.adminslab.com/laravel
    .
  • Changes to .env do nothing: the config is cached. Run
    Code:
    php artisan optimize
    again (as the site user).
  • Composer runs out of memory on a small VPS:
    Code:
    COMPOSER_MEMORY_LIMIT=-1
    in front of the command, or add swap.

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.

Attached Files

Image(s)
       
Reply
Possibly Related Threads…matched by title
Replies:0Views:1
Replies:0Views:3
Replies:0Views:6
Replies:0Views:5
Replies:0Views:97

Users browsing this thread: 1 Guest(s)
Forum Jump: