How to Install Laravel on cPanel
Steps to deploy a Laravel app on cPanel web hosting: choosing the PHP version, uploading the project, composer install, MySQL database, .env, and pointing the domain at the public folder.
cpanelWritten by Aneryan5 min read3 viewsUpdated

Laravel runs on Skyes Hosting cPanel web hosting. Two things matter most: the right PHP version, and only the public/ folder may be reachable from the internet. The rest of the project (including the .env file with your database password) stays outside public_html.
In short: choose the PHP version → upload the project to a folder outside
public_html→composer install→ create a MySQL database → fill in.env→php artisan key:generateandmigrate→ point the domain at thepublic/folder.
Before you start
- An active cPanel web hosting plan and a connected domain.
- Your Laravel project on your computer (or its Git repository).
- SSH access to the hosting. SSH (non-root) is included in every plan. Find your SSH login under SSH Access in cPanel.
- Check which PHP version your Laravel version needs in the Laravel documentation.
Step 1 — Choose the PHP version
- Sign in to cPanel and open Select PHP Version (under Software).
- Choose the PHP version your Laravel app needs, then Set as current.
- On the Extensions tab, make sure the extensions Laravel uses are on, such as
pdo_mysql,mbstring,openssl,tokenizer,xml,ctype,fileinfo, andbcmath.
The cPanel PHP version is also used by the
phpcommand over SSH. Check it withphp -vafter you sign in over SSH. If it differs, sign out and sign in over SSH again.
Step 2 — Upload the project outside public_html
Keep the project in its own folder in your home directory, for example ~/laravel-app, not inside public_html.
Pick one way:
- With Git (recommended): sign in over SSH, then
git clone <repository-url> ~/laravel-app. - With File Manager: zip the project (without
vendor/andnode_modules/), upload it to your home directory with File Manager, then Extract it into alaravel-appfolder.
Don't put the whole project inside
public_html. If you do, files such as.envcan be downloaded by anyone through a browser, including your database password andAPP_KEY.
Step 3 — Install dependencies with Composer
Sign in over SSH, then run:
cd ~/laravel-app
composer install --no-dev --optimize-autoloader
If you see composer: command not found, you have two options:
- Run
composer install --no-devon your computer, then upload the resultingvendor/folder to~/laravel-app. - Or download Composer into the project folder following getcomposer.org/download, then run
php composer.phar install --no-dev --optimize-autoloader.
If your project uses Vite, run npm run build on your computer and upload the resulting public/build folder.
Step 4 — Create a MySQL database
- In cPanel, open MySQL Database Wizard.
- Create a new database, then a database user with a strong password.
- Give that user ALL PRIVILEGES on the database.
- Note the database and user names. cPanel adds your account name as a prefix, for example
youraccount_laravel.
Step 5 — Set up the .env file
cd ~/laravel-app
cp .env.example .env
Open .env (with File Manager or nano .env) and fill in these key settings:
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=youraccount_laravel
DB_USERNAME=youraccount_user
DB_PASSWORD=database-password
Always use
APP_DEBUG=falseon a live website. Withtrue, error pages can show your configuration to visitors.
Then run:
php artisan key:generate
php artisan migrate --force
php artisan storage:link
php artisan config:cache
php artisan route:cache
php artisan view:cache
Make sure storage/ and bootstrap/cache/ are writable:
chmod -R 775 storage bootstrap/cache
Step 6 — Point the domain at the public folder
Pick the method that fits your domain.
Subdomain or addon domain
- In cPanel, open Domains.
- Create a new domain or subdomain, or Manage an existing one.
- Set Document Root to your project's
publicfolder, for examplelaravel-app/public. - Save.
Main domain (public_html)
The main domain's document root usually stays public_html. Instead:
- Move the contents of
~/laravel-app/public(including.htaccessandindex.php) intopublic_html. - Open
public_html/index.phpand change two paths so they point at the project folder:
require __DIR__.'/../laravel-app/vendor/autoload.php';
$app = require_once __DIR__.'/../laravel-app/bootstrap/app.php';
The paths in index.php can differ slightly between Laravel versions. Only change the /../ part so it points at laravel-app, including the storage/framework/maintenance.php line if there is one.
- Because the
publicfolder moved, recreate the storage link over SSH:
ln -s ~/laravel-app/storage/app/public ~/public_html/storage
Step 7 — Run the scheduler (optional)
If your app uses Laravel task scheduling, open Cron Jobs in cPanel and add a cron job that runs every minute:
cd ~/laravel-app && php artisan schedule:run >> /dev/null 2>&1
If it doesn't work
| Symptom | Common cause | Fix |
|---|---|---|
| 500 error with no message | storage/ or bootstrap/cache/ isn't writable, or .env is wrong | Run chmod -R 775 storage bootstrap/cache, check storage/logs/laravel.log |
| File listing or 403 | The domain points at the project folder, not public/ | Change the document root to .../public (Step 6) |
SQLSTATE[HY000] [1045] Access denied | Database/user name without the account prefix, or the user has no access | Use the full names from cPanel, check privileges in MySQL Databases |
PHP version error during composer install | The cPanel PHP version is older than required | Change it in Select PHP Version, then sign in over SSH again |
| Uploaded images don't show | The storage link wasn't created | Run php artisan storage:link or the ln -s command in Step 6 |
.env changes don't apply | Configuration is still cached | Run php artisan config:clear, then php artisan config:cache |
Safe practice
- Never commit
.envto a Git repository. - Keep
APP_DEBUG=falsein production. - Turn on the free SSL in cPanel so the site runs on
https://. - Download a backup with JetBackup before big migrations or Laravel updates.
If you still have problems, contact Skyes Hosting support with your domain and the error message from storage/logs/laravel.log (without passwords).
Was this article helpful?