Server Deployment Guide
Complete installation documentation for deploying Laravel applications across four major hosting environments
cPanelDeployment Guide
Deploy using cPanel's File Manager, MySQL Databases tool, and Terminal — the most widely available shared hosting control panel.
Server Requirements
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.
Upload Project Files
Log in to cPanel
Access your cPanel account (typically at yourdomain.com/cpanel or :2083).
Open File Manager
In cPanel, go to the Files section and click File Manager.
Navigate to public_html
In the left directory tree, click on public_html to open your web root folder.
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.
Extract Files
Right-click the ZIP File
In File Manager, right-click on the uploaded ZIP file and select Extract from the context menu.
Set Extraction Path
In the Extract dialog, enter /public_html as the destination path. Click Extract Files.
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.
Create MySQL Database
Open MySQL Databases
In cPanel, go to the Databases section and click MySQL® Databases.
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).
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.
Add User to Database
Scroll to Add User To Database. Select your newly created user and database from the dropdowns. Click Add.
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.
Configure .env File
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.
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!Run Composer & Artisan Commands
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/cacheApache & .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.
Final Steps
Set PHP Version to 8.2
In cPanel, go to Software → Select PHP Version. Change to 8.2 and click Set as current.
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.
Enable SSL Certificate
In cPanel, navigate to Security → SSL/TLS Status. Click Run AutoSSL.
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.
Troubleshooting
| Common Issue | Solution |
|---|---|
| 500 Internal Server Error | Check storage/logs/laravel.log; set APP_DEBUG=true temporarily |
| Database connection failed | Verify DB credentials include cPanel prefix (e.g. cpanelusername_myapp) |
| 404 on all routes | Ensure document root is set to public_html/public and mod_rewrite is enabled |
| Blank white page | Run php artisan config:clear via Terminal; confirm PHP version is 8.2 |
| Composer not found | Download manually: php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" |
| Permission denied errors | Run chmod -R 775 storage bootstrap/cache from Terminal |
| Images/files not loading | Run php artisan storage:link to create the public storage symlink |
