13/11/2025
Web server Installation
- Go to caddy https://caddyserver.com/
- Select Window amd64 -> Download
- Install PHP https://windows.php.net/download/
- Select VS17 x64 Non Thread Safe -> zip -> Download
- Create PHP File web/www/index.php
<?php phpinfo() ?>
- Create Config File -> Caddyfile
# Caddyfile
import snippets/*
# Use the "yii2-app" snippet for our site:
import yii-app localhost C:\Projects\webapp\portalv2\web
## reverse proxy example
#domain.my {
#tls C:\caddy\ssl\2025\bundle.crt C:\caddy\ssl\2025\site.key
#reverse_proxy localhost:3000
#}
## redirect old domain to new domain example
#domain.my {
# redir https://domain.my/
#}
- Create Snippet /snippets/yii-app
#/snippets/yii-app
# yii-app
# {args.0} represents the root url of the app. Example domain.com.
# {args.1} represents the root path to the app. Example C:\path
(yii-app) {
{args[0]} {
# Resolve the root directory for the app
root * {args[1]}\www
# Provide Zstd and Gzip compression
encode zstd gzip
#tls C:\caddy\ssl\2025\bundle.crt C:\caddy\ssl\2025\site.key
header {
# HIDE SERVER INFO
-server
# Enable HTTP caching
Cache-Control "no-store"
#HSTS
Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
#CSP
content-security-policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: *; img-src 'self' data: *; style-src 'self' 'unsafe-inline' *; connect-src 'self' *; font-src 'self' data: *; frame-src 'self' *; object-src 'none'; media-src 'self' *"
permissions-policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()"
x-content-type-options "nosniff"
x-xss-protection "1; mode=block"
x-frame-options "SAMEORIGIN"
Referrer-Policy "strict-origin-when-cross-origin"
Set-Cookie (.*) "$1; SameSite=None; Secure"
defer
}
# Modify the Set-Cookie header to add secure flags
header >Set-Cookie (.*) "{http.response.header.Set-Cookie[0]}; HttpOnly; Secure; SameSite=Lax"
@static {
file
path *.ico *.css *.js *.gif *.webp *.avif *.jpg *.jpeg *.png *.svg *.woff *.woff2
}
handle /* {
#respond {args[1]}\www
@indexFiles file {
try_files {path} {path}/index.php index.php
try_files {path} {path}/index.php
split_path .php
}
rewrite @indexFiles {http.matchers.file.relative}
}
handle /admin/* {
#respond {args[1]}\admin\www
@indexFiles2 file {
try_files {path} {path}/admin/index.php /admin/index.php
try_files {path} {path}/admin/index.php
split_path .php
}
rewrite @indexFiles2 {http.matchers.file.relative}
}
# redirect my to / from google
#redir /my/ /
#forbid php from accessed
@not_no_php {
not path /assets/*
path *.php
}
@blocked {
path /assets/*.php
}
respond @blocked 403
php_fastcgi @not_no_php 127.0.0.1:9001 {
env front_controller_active true
resolve_root_symlink
dial_timeout 60s
read_timeout 300s
write_timeout 300s
}
log {
output file access.log
}
# Allow caddy to serve static files
file_server
@dotFiles {
path */.*
not path /.well-known/*
}
}
}
- Run as service (optional)
sc.exe create caddy start= auto binPath= "YOURPATH\caddy.exe run"
- Run Php
cd YOUR/PHP/PATH
.\php-cgi.exe -c .\php.ini-development -b 127.0.0.1:9001
- Check if php running on port
netstat -an | findstr 9001
- add repo
https://gitlab.com/allif.ahmad92/portalv2-dynaweb
git clone https://gitlab.com/allif.ahmad92/portalv2-dynaweb.git web
- Install Composer https://getcomposer.org/download/
- select php path
- run composer install
composer install --ignore-platform-reqs
- Download Mysql https://dev.mysql.com/downloads/file/?id=546163
No Comments