inkphp GitHub 中文

Deployment

nginx

server {
    listen 80;
    server_name example.com;
    root /var/www/myapp/public;              # only public/ is the docroot

    location ~ /\.(?!well-known/) { return 404; }
    location ~* \.(php|phtml|phar)$ { try_files /__never__ @ink; }   # any .php URL goes to the front controller
    location / { try_files $uri @ink; }       # real static files directly, everything else to the front controller

    location @ink {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
        fastcgi_param SCRIPT_NAME /index.php;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        fastcgi_pass unix:/run/php/php8.4-fpm.sock;
    }
}

Baota panel / Apache

Point the site root at the project's public directory. Baota rewrite rule:

location / { try_files $uri /index.php$is_args$args; }

Apache uses the bundled public/.htaccess.

Permissions

Cloudflare

Use nginx's real_ip module to restore CF-Connecting-IP, and client_ip() is the visitor's IP. Set trust_proxy to true only when the origin accepts Cloudflare's ranges alone.

Scanners

Block /.env, /wp-admin and similar in nginx, with a separate log; don't add PHP hooks for them.

Updates

git pull (or upload) → php bin/ink migrate → php bin/ink check. There is no build step. On a shared PHP-FPM pool don't use fastcgi_param PHP_ADMIN_VALUE (it leaks into other sites' requests); give the app its own pool if you need open_basedir.