Modern PHP development has come a long way, and today’s frameworks offer tools that make development seamless, maintainable, and scalable, like Laravel. But when it comes to going live, deploying your web application isn’t quite as simple as uploading files to a folder, especially if you’re using advanced tooling, routing, and environment-based configuration.
In this comprehensive, 2025-ready deployment guide, you’ll learn how to bring your PHP framework (Laravel)-based app online using two common environments:
-
Shared hosting with SSH (cPanel-based)
-
A virtual private server (VPS) running Ubuntu or Debian
This tutorial is designed to work with virtually any provider—Nest Nepal, Hostinger, A2 Hosting, or your own VPS.
Before You Begin: System Requirements
Before jumping into deployment, make sure the following tools and conditions are met:
-
You’ve built and tested your app locally using the latest version of Laravel (Laravel 11)
-
Your hosting environment provides SSH access (either via cPanel Terminal or full root access on a VPS)
-
Git access, or an FTP/SFTP client if Git is unavailable
-
PHP version 8.1 or higher is installed on the server
-
Composer for Laravel is installed on the server
-
A database like MySQL or MariaDB is ready to be connected
Option 1: Deploying on cPanel with SSH Access
This is the more accessible option for many developers, especially those using shared hosting plans.
1. Upload the App
Start by zipping your project directory, but exclude the vendor/
folder and .env
file to keep things secure and reduce the size.
You can upload it using the File Manager or clone the repository directly via Git if available.
2. File Placement and Structure
Do not place the entire app inside the public_html/
directory. Instead, upload the full project to a separate folder, like /home/username/myapp/
. Then:
-
Either copy the contents of your
public/
folder topublic_html/
-
Or, if symbolic links are supported, link the
public/
directory topublic_html/
3. Set Permissions
Run the following via the terminal:
This ensures the necessary directories are writable.
4. Environment Configuration
Upload your .env
file separately and update the database credentials accordingly.
Then, generate the app key using:
5. Database Setup
Use cPanel’s MySQL tools to create your database and user, then assign privileges.
Once the .env
is ready, migrate your database:
6. Update .htaccess for Routing
Make sure the .htaccess
inside public_html/
is properly handling route requests:
Option 2: Deploying on VPS (Ubuntu/Debian)
This method gives you full control over the environment and is preferred for more complex or high-performance apps.
1. Connect via SSH
2. Install Required Software
If not already set up, install all necessary packages:
3. Upload or Clone the Code
Navigate to your web directory and pull the source code:
4. Fix Ownership and Permissions
5. Create the Database
Log in to MySQL and create your database and user:
Update the environment config and run:
6. Set Up Nginx
Here’s a basic Nginx config block:
Restart Nginx:
Post-Deployment Checklist
After the app is live:
-
Cache configuration and routes:
-
Set up workers if you use queues:
-
Add a cron job for scheduled tasks:
Common Errors and Quick Fixes
Issue | Cause | Fix |
---|---|---|
500 Internal Error | Bad file permissions, no .env |
Check logs, set correct permissions |
Class Not Found | Missing vendor folder | Run composer install |
Forbidden Access | Wrong root directory | Verify the Nginx path or .htaccess |
Final Thoughts
Deploying your modern PHP Laravel application on shared or private servers doesn’t have to be painful. By following structured steps—uploading your code properly, configuring permissions, managing environment variables, and setting up web servers—you can go live with confidence.
For advanced workflows, consider integrating tools like GitHub Actions, Laravel Forge, Envoyer, or Ploi to automate deployment.
Happy launching!