Ubuntu 22.04PHP 8.2Laravel 10.10MySQL 8.0NGINX/Apache

Server Deployment Guide

Complete installation documentation for deploying Laravel applications across four major hosting environments

L
P
8.2
Production Ready Stack

cPanelDeployment Guide

Deploy using cPanel's File Manager, MySQL Databases tool, and Terminal — the most widely available shared hosting control panel.

01

Server Requirements

PHP VERSION
8.2
LARAVEL
10.10
DATABASE
MySQL 8.0
WEB SERVER
Apache + mod_rewrite
COMPOSER
Required
TERMINAL
Required

Required PHP extensions: openssl, pdo, mbstring, tokenizer, json, gd, curl, zip, zlib, fileinfo, exif, bcmath. Ensure mod_rewrite is enabled in Apache for URL rewriting.

02

Upload Project Files

1

Log in to cPanel

Access your cPanel account (typically at yourdomain.com/cpanel or :2083).

2

Open File Manager

In cPanel, go to the Files section and click File Manager.

3

Navigate to public_html

In the left directory tree, click on public_html to open your web root folder.

4

Upload the ZIP File

Click the Upload button in the toolbar. Drag and drop your [project-name]-web-[version].zip file or click Select File. Wait for progress bar to reach 100%.

You can also upload via FTP/SFTP using FileZilla. Find your FTP credentials under Files → FTP Accounts in cPanel.

03

Extract Files

1

Right-click the ZIP File

In File Manager, right-click on the uploaded ZIP file and select Extract from the context menu.

2

Set Extraction Path

In the Extract dialog, enter /public_html as the destination path. Click Extract Files.

3

Set Document Root to /public

In cPanel, go to Domains → your domain → Document Root and set it to /public_html/public. Click Save.

If your host does not allow changing the document root, move all files from the public folder into public_html and edit index.php to update the paths to bootstrap/app.php.

04

Create MySQL Database

1

Open MySQL Databases

In cPanel, go to the Databases section and click MySQL® Databases.

2

Create New Database

Under Create New Database, enter your database name (e.g. myapp) and click Create Database. cPanel prefixes it with your username (e.g. cpanelusername_myapp).

3

Add a MySQL User

Scroll to MySQL Users → Add New User. Enter a username (e.g. script) and a strong password. Use the Password Generator. Click Create User.

4

Add User to Database

Scroll to Add User To Database. Select your newly created user and database from the dropdowns. Click Add.

5

Grant All Privileges

On the Manage User Privileges screen, check ALL PRIVILEGES at the top. Click Make Changes.

Note the full database name and username (with cPanel prefix). You will need these exact values for your .env file.

05

Configure .env File

1

Copy .env.example

In File Manager, find .env.example in your project root. Right-click → Copy. Paste in the same folder and rename to .env.

2

Edit the .env File

Right-click .env → Edit (or HTML Editor). Update the values below then click Save Changes.

APP_NAME="Your App Name"
                        APP_ENV=production
                        APP_KEY=   # Will be generated via artisan key:generate
                        APP_DEBUG=false
                        APP_URL=https://yourdomain.com

                        DB_CONNECTION=mysql
                        DB_HOST=127.0.0.1
                        DB_PORT=3306
                        DB_DATABASE=cpanelusername_myapp    # Full prefixed database name
                        DB_USERNAME=cpanelusername_script   # Full prefixed username
                        DB_PASSWORD=YourStrongPassword123!
06

Run Composer & Artisan Commands

Open cPanel built-in terminal: go to Advanced → Terminal. This gives you SSH-like access directly in the browser.
cd ~/public_html

                        # Install Composer dependencies
                        composer install --no-dev --optimize-autoloader

                        # If Composer is not in PATH, download it first:
                        php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
                        php composer-setup.php
                        php composer.phar install --no-dev --optimize-autoloader

                        # Generate application key
                        php artisan key:generate

                        # Run database migrations
                        php artisan migrate --force

                        # Create symbolic link for storage
                        php artisan storage:link

                        # Cache configuration and routes for performance
                        php artisan config:cache
                        php artisan route:cache
                        php artisan view:cache

                        # Fix file permissions
                        chmod -R 755 ~/public_html
                        chmod -R 775 ~/public_html/storage
                        chmod -R 775 ~/public_html/bootstrap/cache
07

Apache & .htaccess Configuration

cPanel uses Apache with mod_rewrite by default. Laravel's public/.htaccess file is already included in the project. Ensure it exists after extraction.

# public/.htaccess — already included in project
                        <IfModule mod_rewrite.c>
                            <IfModule mod_negotiation.c>
                                Options -MultiViews -Indexes
                            </IfModule>
                            RewriteEngine On
                            RewriteCond %{HTTP:Authorization} .
                            RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
                            RewriteCond %{REQUEST_FILENAME} !-d
                            RewriteCond %{REQUEST_URI} (.+)/$
                            RewriteRule ^ %1 [L,R=301]
                            RewriteCond %{REQUEST_FILENAME} !-d
                            RewriteCond %{REQUEST_FILENAME} !-f
                            RewriteRule ^ index.php [L]
                        </IfModule>

To enable free SSL in cPanel, go to Security → SSL/TLS Status and click Run AutoSSL to install a free Let's Encrypt certificate.

08

Final Steps

1

Set PHP Version to 8.2

In cPanel, go to Software → Select PHP Version. Change to 8.2 and click Set as current.

2

Enable Required PHP Extensions

On the PHP version page, ensure these are enabled: openssl, pdo, pdo_mysql, mbstring, tokenizer, json, gd, curl, zip, zlib, fileinfo, exif, bcmath. Click Save.

3

Enable SSL Certificate

In cPanel, navigate to Security → SSL/TLS Status. Click Run AutoSSL.

4

Open Your Website

Navigate to https://yourdomain.com. The installation wizard will guide you through any remaining setup.

Installation complete! Verify document root is set to public_html/public, PHP is 8.2, and required extensions are enabled.

09

Troubleshooting

Common IssueSolution
500 Internal Server ErrorCheck storage/logs/laravel.log; set APP_DEBUG=true temporarily
Database connection failedVerify DB credentials include cPanel prefix (e.g. cpanelusername_myapp)
404 on all routesEnsure document root is set to public_html/public and mod_rewrite is enabled
Blank white pageRun php artisan config:clear via Terminal; confirm PHP version is 8.2
Composer not foundDownload manually: php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
Permission denied errorsRun chmod -R 775 storage bootstrap/cache from Terminal
Images/files not loadingRun php artisan storage:link to create the public storage symlink