Deploying Laravel 12: From Local Development to Production for Beginners
Laravel is one of the most powerful PHP frameworks, and Laravel 12 brings some exciting features and improvements. But building your Laravel application is only half the journey. The next step is getting it live so the world can use it!
In this blog, we’ll walk through step-by-step how to deploy your Laravel 12 application from your local development environment to a live production server. This guide is designed for beginners, so even if you’ve never deployed a Laravel app before, you’ll be able to follow along.
🛠️ What You Need Before You Start
Before jumping in, make sure you have:
- A Laravel 12 application running locally
- A live server (VPS or shared hosting) – we recommend DigitalOcean, Linode, or Laravel Forge for beginners
- A domain name (optional but recommended)
- Basic knowledge of SSH, FTP, or a control panel like cPanel
🧪 Step 1: Build and Test Your App Locally
Make sure your app is fully functional on your local system.
✅ Use .env for local config
✅ Run php artisan serve to test
✅ Check that your database, routes, and views work
✅ Run php artisan migrate and php artisan db:seed to test migrations and dummy data
🧳 Step 2: Prepare for Deployment
Laravel uses environment-specific settings, so let’s prepare:
2.1 Set APP_ENV to production
In your .env file (on the server), set:
APP_ENV=production
APP_DEBUG=false
2.2 Set up Git or ZIP your app
You can either:
- Push your code to GitHub/GitLab, then pull it on the server
- Or ZIP your project and upload it via FTP or control panel
🌐 Step 3: Choose a Hosting Option
Option 1: Shared Hosting (e.g., Namecheap, Hostinger)
- Use cPanel or FTP to upload your files
- Set
publicfolder as your root directory - Move files from
/publicto root or configure.htaccess
Option 2: VPS or Cloud Hosting (e.g., DigitalOcean)
Recommended for better performance and control.
- SSH into your server
- Install PHP, MySQL, Composer, and NGINX/Apache
- Create a directory for your app (e.g.,
/var/www/laravel-app) - Clone or upload your Laravel app into this folder
🔧 Step 4: Server Configuration
4.1 Set correct permissions
sudo chown -R www-data:www-data /var/www/laravel-app
sudo chmod -R 755 /var/www/laravel-app
Make sure the storage and bootstrap/cache folders are writable:
sudo chmod -R 775 storage
sudo chmod -R 775 bootstrap/cache
4.2 Set up a Virtual Host (Apache example)
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/laravel-app/public
<Directory /var/www/laravel-app/public>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Enable .htaccess if using Apache.
⚙️ Step 5: Final Laravel Setup on the Server
Run the following commands inside your app directory:
composer install
php artisan key:generate
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
--forcewill skip the confirmation prompts, useful for production.
🔒 Step 6: Set File Permissions & Environment
- Ensure
.envis correctly configured with your production database, mail, and other credentials. - Do not upload your local
.envfile. Create a new one on the server and configure it properly.
🧼 Step 7: Remove Development Files (optional)
For security:
- Delete
.env.example,.git, and any test routes - Remove unnecessary logs from
storage/logs
📶 Step 8: Connect Your Domain
If using a VPS:
- Point your domain’s A record to your server IP
- Wait for DNS to propagate
- Use Let’s Encrypt to install an SSL certificate (https)
sudo apt install certbot python3-certbot-apache
sudo certbot --apache
🚀 You're Live!
Visit your domain, and your Laravel 12 app should now be online!
✅ Bonus Tips for Production
- Use a process monitor like Supervisor for queues:
sudo apt install supervisor
- Enable caching for better performance:
php artisan config:cache
php artisan route:cache
Set up daily backups of your database
Monitor logs with tools like Laravel Telescope or external services
🧠 Conclusion
Deploying Laravel 12 may sound overwhelming at first, but once you understand the steps, it becomes a repeatable and smooth process. Whether you’re using shared hosting or a full-blown VPS, this guide gives you the essential building blocks to get your app from local to live.
Keep experimenting, keep deploying, and soon this process will feel second nature.
Projects to explore next
Source-code projects from the KritiMyantra catalogue. Check each project's details before buying.
Flask Authentication System (Free Version) - Kritim Yantra
🛠 Features✔ Google & GitHub Authentication✔ User Registration & Login✔ Profile/Dashboard Access✔ Secure & Mi...
Flask Blog CMS with Admin Dashboard — Python Source Code
A Flask-based blogging website with a built-in admin dashboard. Manage articles, images, categories, tags and featured p...
Laravel 12 + ReactJS Starter Kit: Add Multi-Language Support (Arabic, English, Spanish) with Blog CRUD
🚀 Installation & Setup Download & Extract Get the ZIP from kritimyantra.com and extract it. Includes preconfigu...
Comments
No comments yet. Be the first to comment.
Sign in to join the discussion.