Skip to content
Skyes Hosting

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 5 min read3 viewsUpdated

How to Install Laravel on cPanel

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:generate and migrate → point the domain at the public/ 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

  1. Sign in to cPanel and open Select PHP Version (under Software).
  2. Choose the PHP version your Laravel app needs, then Set as current.
  3. On the Extensions tab, make sure the extensions Laravel uses are on, such as pdo_mysql, mbstring, openssl, tokenizer, xml, ctype, fileinfo, and bcmath.

The cPanel PHP version is also used by the php command over SSH. Check it with php -v after 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/ and node_modules/), upload it to your home directory with File Manager, then Extract it into a laravel-app folder.

Don't put the whole project inside public_html. If you do, files such as .env can be downloaded by anyone through a browser, including your database password and APP_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-dev on your computer, then upload the resulting vendor/ 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

  1. In cPanel, open MySQL Database Wizard.
  2. Create a new database, then a database user with a strong password.
  3. Give that user ALL PRIVILEGES on the database.
  4. 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=false on a live website. With true, 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

  1. In cPanel, open Domains.
  2. Create a new domain or subdomain, or Manage an existing one.
  3. Set Document Root to your project's public folder, for example laravel-app/public.
  4. Save.

Main domain (public_html)

The main domain's document root usually stays public_html. Instead:

  1. Move the contents of ~/laravel-app/public (including .htaccess and index.php) into public_html.
  2. Open public_html/index.php and 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.

  1. Because the public folder 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

SymptomCommon causeFix
500 error with no messagestorage/ or bootstrap/cache/ isn't writable, or .env is wrongRun chmod -R 775 storage bootstrap/cache, check storage/logs/laravel.log
File listing or 403The domain points at the project folder, not public/Change the document root to .../public (Step 6)
SQLSTATE[HY000] [1045] Access deniedDatabase/user name without the account prefix, or the user has no accessUse the full names from cPanel, check privileges in MySQL Databases
PHP version error during composer installThe cPanel PHP version is older than requiredChange it in Select PHP Version, then sign in over SSH again
Uploaded images don't showThe storage link wasn't createdRun php artisan storage:link or the ln -s command in Step 6
.env changes don't applyConfiguration is still cachedRun php artisan config:clear, then php artisan config:cache

Safe practice

  • Never commit .env to a Git repository.
  • Keep APP_DEBUG=false in 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?