Caddy: Difference between revisions

Onny (talk | contribs)
Onny (talk | contribs)
Caddy with FrankenPHP plugin
Line 88: Line 88:


You'll need a [[Phpfpm|PHP-FPM]] socket listening on Unix socket path <code>/var/run/phpfpm/localhost.sock</code>.
You'll need a [[Phpfpm|PHP-FPM]] socket listening on Unix socket path <code>/var/run/phpfpm/localhost.sock</code>.
=== PHP with FrankenPHP ===
Instead of Caddy, the FrankenPHP package can be defined as drop-in replacement for the Caddy-service which will  allow serving PHP applications without additional external process managers. In case you want to use FrankenPHP as an additional Caddy plugin, you can try this modifications
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
  (self: super: {
    phpWithEmbed = super.php.override {
      embedSupport = true;
      ztsSupport = true;
      staticSupport = super.stdenv.hostPlatform.isDarwin;
      zendSignalsSupport = false;
      zendMaxExecutionTimersSupport = super.stdenv.hostPlatform.isLinux;
    };
    caddy = super.caddy.overrideAttrs (oldAttrs: {
      buildInputs =
        (oldAttrs.buildInputs or [ ])
        ++ [
          self.watcher
          self.phpWithEmbed.unwrapped
          self.brotli
        ]
        ++ self.phpWithEmbed.unwrapped.buildInputs;
      preBuild = ''
        export CGO_CFLAGS="$(${self.phpWithEmbed.unwrapped.dev}/bin/php-config --includes)"
        export CGO_LDFLAGS="-DFRANKENPHP_VERSION=${self.frankenphp.version} \
          $(${self.phpWithEmbed.unwrapped.dev}/bin/php-config --ldflags) \
          $(${self.phpWithEmbed.unwrapped.dev}/bin/php-config --libs)"
      '';
    });
  })
];
services.caddy = {
  enable = true;
  package = pkgs.caddy.withPlugins {
    plugins = [
      "github.com/dunglas/frankenphp@v1.12.1"
    ];
    hash = "sha256-uqVHU4PkriIJ67uf2JqggL4LpXMN1mx9Jo2JRu7bjFE=";
  };
  virtualHosts."http://localhost".extraConfig = ''
    respond "Hello, world!"
  '';
};
</syntaxhighlight>


=== Plug-ins ===
=== Plug-ins ===