Deployment
β± Estimated reading time: 2 min
Deployment of a CodeIgniter Application (CodeIgniter 4)
Deploying a CodeIgniter 4 app means moving it from local development to a production server safely, securely, and efficiently.
1. Server Requirements
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.)
2. Project Structure for Deployment
Your server should point to the public/ directory as the web root:
β This protects core files from public access
3. Upload Project Files
Options:
-
Git (
git clone) -
FTP/SFTP
-
CI/CD pipeline
Recommended:
4. Install Dependencies
Inside the project folder:
β Excludes development packages
β Optimized for production
5. Environment Configuration
Create .env file:
β οΈ Never commit .env to Git
6. Set Folder Permissions
Make writable/ writable:
Owner example:
7. Run Migrations (If Used)
(Optional) Seed data:
8. Apache Configuration
Enable mod_rewrite
Virtual Host Example
Restart Apache:
9. Nginx Configuration (Alternative)
10. Disable Debugging (Critical)
In production:
β Debug toolbar disabled
β Errors hidden from users
β Logs still enabled
11. Enable HTTPS
-
Use Letβs Encrypt (Certbot)
-
Force HTTPS using filter:
12. Cache & Performance Setup
-
Enable OPcache in
php.ini -
Configure CodeIgniter cache (file/Redis)
-
Enable gzip compression
-
Use CDN for assets
13. Security Checklist
β
.env not public
β
writable/ permissions correct
β
Errors hidden
β
HTTPS enabled
β
Database credentials secured
14. Common Deployment Issues
| 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 |
15. Post-Deployment Testing
-
Test login & forms
-
Test file uploads
-
Check logs
-
Verify API endpoints
-
Load test critical pages
Summary
-
Point server to
public/ -
Use production environment
-
Secure
.envand permissions -
Run migrations
-
Enable HTTPS & caching
Register Now
Share this Post
β Back to Tutorials