After setting up your Laravel application on a Digital Ocean droplet with cPanel/WHM, the next critical step is configuring your domain and implementing SSL certificates. This guide walks you through the complete process of connecting your domain to your server and securing it with HTTPS.
Understanding the Domain-Server Connection
When you deploy a Laravel application, you need to establish the connection between your domain name and your server IP address. This involves DNS configuration, server-side setup, and proper redirects to ensure a seamless user experience.
Step 1: DNS Configuration in Your Domain Registrar
Setting Up DNS Records
For this example, we'll use a domain purchased through GoDaddy, but the process is similar for other registrars.
Access your domain's DNS management:
- Login to your domain registrar (GoDaddy, Namecheap, etc.)
- Navigate to DNS Management for your domain
- Add the following DNS records:
Understanding DNS Record Types
- @ Record: Points your root domain (yourdomain.com) to your server
- www Record: Handles www.yourdomain.com requests
- server Record: Creates server.yourdomain.com for WHM access
Step 2: WHM Hostname Configuration
Setting Up Server Hostname
In WHM, navigate to Server Configuration → Basic WHM Setup:
Configure these essential settings:
This configuration ensures your server is properly identified and can handle nameserver requests.
Step 3: Digital Ocean DNS Zone Setup
Adding Domain to Digital Ocean
Even though you're using external DNS, adding your domain to Digital Ocean provides additional DNS redundancy:
- Access Digital Ocean Control Panel
- Navigate to Networking → Domains
- Add your domain: yourdomain.com
- Create these A records:
Step 4: Laravel Application Configuration
Updating Environment Variables
Once DNS propagation is complete (usually 24-48 hours), update your Laravel .env
file:
Clearing Laravel Caches
After updating your environment file:
Step 5: Implementing URL Redirects
Root .htaccess Configuration
Create/update /home/your_username/public_html/.htaccess
:
Step 6: SSL Certificate Implementation
Option 1: Let's Encrypt (Free SSL)
Most cPanel installations include Let's Encrypt integration:
- Navigate to cPanel → SSL/TLS → Let's Encrypt
- Select your domain
- Check "Include www" option
- Click "Issue" to generate certificate
Option 2: Cloudflare SSL (Recommended)
For better performance and additional security features:
- Create Cloudflare account
- Add your domain to Cloudflare
- Configure SSL/TLS settings:SSL Mode: Full (Strict)
- Edge Certificates: Enabled
- Always Use HTTPS: Enabled
Option 3: Custom SSL Certificate
For purchased SSL certificates:
- Navigate to cPanel → SSL/TLS → Manage SSL
- Upload certificate files:Certificate (CRT)
- Private Key
- Certificate Authority Bundle (if applicable)
- Install certificate for your domain
Step 7: Testing Your Configuration
DNS Propagation Check
Use online tools to verify DNS propagation:
SSL Certificate Validation
Test SSL implementation:
Application Testing
Verify these URLs work correctly:
https://yourdomain.com
(main site)https://www.yourdomain.com
(should redirect to non-www)http://yourdomain.com
(should redirect to HTTPS)
Step 8: OAuth Application Updates
Updating External OAuth Providers
Google OAuth Console:
GitHub OAuth App:
Facebook OAuth (if applicable):
Common Issues and Solutions
SSL Mixed Content Errors
If you're getting mixed content warnings:
DNS Not Propagating
- Check TTL settings (lower values propagate faster)
- Use different DNS checkers to verify global propagation
- Clear local DNS cache:
ipconfig /flushdns
(Windows) orsudo dscacheutil -flushcache
(Mac)
WHM Access After Domain Change
After domain configuration, your WHM URL will change to:
Vite Development Assets Loading
Remove the Vite hot file to prevent development asset loading:
Performance Considerations
CDN Integration
Consider implementing a CDN like Cloudflare or AWS CloudFront for:
- Faster global content delivery
- DDoS protection
- Additional SSL/security features
- Bandwidth savings
Database Optimization
Update your database connection for production:
What's Next?
With your domain configured and SSL implemented, your Laravel application is now accessible via HTTPS with proper redirects. The next step is performance optimization, which we'll cover in our upcoming guide on server-level optimizations and caching strategies.
Domain and SSL configuration can be complex, but having the right tools and templates makes it manageable. At ScriptVil, we're building a platform where developers can find and share automation scripts for deployment tasks like these. From SSL certificate automation to DNS configuration templates, our marketplace will help developers streamline their deployment workflows.
Security Best Practices
- Always use HTTPS in production
- Implement proper redirect chains (HTTP → HTTPS, www → non-www)
- Keep SSL certificates updated and monitored
- Use strong passwords for all accounts
- Regularly update server software and dependencies
Ready to optimize your Laravel application's performance? Our next guide covers server-level optimizations, caching strategies, and performance monitoring.