Last active
July 3, 2025 07:47
-
-
Save siagung/45417d3121c451c0143b841b89eff960 to your computer and use it in GitHub Desktop.
Setup Caddy+FRANKENPHP 1.7 CODEIGNITER 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FRANKENPHP 1.7 CODEIGNITER 4 | |
| $ sudo nano /etc/caddy/Caddyfile | |
| # Redirect www → primary domain | |
| www.domain1.com { | |
| redir https://domain1.com{uri} permanent | |
| } | |
| # Domain utama: serve CI4 via Frankennphp | |
| domain1.com { | |
| root * /var/www/domain1.com/public | |
| # PHP configuration | |
| php { | |
| env APP_ENV development | |
| env APP_DEBUG true | |
| } | |
| # Handle PHP files and fallback routing | |
| @phpFiles path *.php | |
| try_files @phpFiles {path} /index.php?{query} | |
| # File server configuration | |
| file_server { | |
| index index.php index.html | |
| } | |
| # Optional: Add logging for debugging | |
| # log { | |
| # output file /var/log/caddy/domain1.com.log | |
| # level DEBUG | |
| # } | |
| # Optional: Handle common static files | |
| @static { | |
| file | |
| path *.css *.js *.ico *.png *.jpg *.jpeg *.gif *.svg *.woff *.woff2 *.ttf *.eot | |
| } | |
| handle @static { | |
| file_server | |
| header Cache-Control "public, max-age=31536000" | |
| } | |
| } | |
| subdomain.domain1.com { | |
| root * /var/www/subdomain.domain1.com/public | |
| # PHP configuration | |
| php { | |
| env APP_ENV production | |
| env APP_DEBUG false | |
| } | |
| # Handle PHP files and fallback routing | |
| @phpFiles path *.php | |
| try_files @phpFiles {path} /index.php?{query} | |
| # File server configuration | |
| file_server { | |
| index index.php index.html | |
| } | |
| # Optional: Handle common static files | |
| @static { | |
| file | |
| path *.css *.js *.ico *.png *.jpg *.jpeg *.gif *.svg *.woff *.woff2 *.ttf *.eot | |
| } | |
| handle @static { | |
| file_server | |
| header Cache-Control "public, max-age=31536000" | |
| } | |
| } | |
| ---------------------------------------------- | |
| $ sudo systemctl daemon-reexec | |
| $ sudo systemctl daemon-reload | |
| $ sudo systemctl restart caddy | |
| ---------------------------------------------- | |
| $ sudo nano /etc/systemd/system/caddy.service | |
| [Unit] | |
| Description=Caddy FrankenPHP Web Server | |
| Documentation=https://caddyserver.com/docs/ | |
| After=network.target | |
| [Service] | |
| Type=exec | |
| ExecStart=/usr/local/bin/caddy run --config /etc/caddy/Caddyfile --adapter caddyfile | |
| ExecReload=/usr/local/bin/caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile | |
| Restart=on-failure | |
| RestartSec=2s | |
| User=caddy | |
| Group=caddy | |
| WorkingDirectory=/var/www | |
| TimeoutStopSec=5s | |
| PrivateTmp=true | |
| ProtectSystem=full | |
| # izinkan Caddy menulis ke /run agar socket bisa dibuat | |
| ReadWritePaths=/var/www/frankenphp | |
| # grant bind-to-privileged-ports | |
| AmbientCapabilities=CAP_NET_BIND_SERVICE | |
| CapabilityBoundingSet=CAP_NET_BIND_SERVICE | |
| # allow ambient caps to actually be set | |
| NoNewPrivileges=false | |
| #AmbientCapabilities=CAP_NET_BIND_SERVICE0 | |
| LimitNOFILE=1048576 | |
| LimitNPROC=512 | |
| [Install] | |
| WantedBy=multi-user.target | |
| ----------------------------------------- | |
| ## mariadb almalinux 9 | |
| $ sudo dnf install -y mariadb mariadb-server | |
| $ sudo mysql_secure_installation | |
| Switch to unix_socket authentication [Y/n] n | |
| Set root password? [Y/n] Y | |
| Remove anonymous users? [Y/n] Y | |
| Disallow root login remotely? [Y/n] Y | |
| Remove test database and access to it? [Y/n] Y | |
| Reload privilege tables now? [Y/n] Y | |
| CREATE DATABASE db_database CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | |
| CREATE USER 'userdb'@'localhost' IDENTIFIED BY 'passworduser'; | |
| GRANT ALL PRIVILEGES ON db_database.* TO 'userdb'@'localhost'; | |
| FLUSH PRIVILEGES; | |
| /home/ptmkl/dbssl/db_file.sql | |
| sudo mysql -u userdb -p db_database < /home/user/db_file.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment