Deploying a CodeIgniter 4 app means moving it from local development to a production server safely, securely, and efficiently.
Ensure your production server has:
PHP 7.4+
Extensions: intl, mbstring, openssl, json, mysqlnd
Web server: Apache or Nginx
Composer (recommended)
Database server (MySQL, PostgreSQL, etc.)
Your server should point to the public/ directory as the web root:
✔ This protects core files from public access
Options:
Git (git clone)
FTP/SFTP
CI/CD pipeline
Recommended:
Inside the project folder:
✔ Excludes development packages
✔ Optimized for production
Create .env file:
⚠️ Never commit .env to Git
Make writable/ writable:
Owner example:
(Optional) Seed data:
Restart Apache:
In production:
✔ Debug toolbar disabled
✔ Errors hidden from users
✔ Logs still enabled
Use Let’s Encrypt (Certbot)
Force HTTPS using filter:
Enable OPcache in php.ini
Configure CodeIgniter cache (file/Redis)
Enable gzip compression
Use CDN for assets
✅ .env not public
✅ writable/ permissions correct
✅ Errors hidden
✅ HTTPS enabled
✅ Database credentials secured
| Issue | Fix |
|---|---|
| 403/404 errors | Wrong document root |
| Blank page | Check logs in writable/logs/ |
| CSS/JS not loading | Incorrect baseURL |
| Permission denied | Fix writable/ permissions |
Test login & forms
Test file uploads
Check logs
Verify API endpoints
Load test critical pages
Point server to public/
Use production environment
Secure .env and permissions
Run migrations
Enable HTTPS & caching
Take quizzes related to this topic and see where you stand!
Start Quiz Now