Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpfpm: add options #63962

Closed
wants to merge 3 commits into from
Closed

phpfpm: add options #63962

wants to merge 3 commits into from

Conversation

Izorkin
Copy link
Contributor

@Izorkin Izorkin commented Jun 30, 2019

Motivation for this change

Add options globalPhpOptions to configure php.ini for all PHP-FPM pools.
Add option listenTCP to enable work PHP-FPM with network address.

cc @etu

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@Izorkin Izorkin changed the title phpfpm: add options globalPhpOptions phpfpm: add options Jul 1, 2019
@aanderse
Copy link
Member

aanderse commented Jul 1, 2019

I want to highlight that there was an option to add configuration globally across all php.ini files that you removed in #63156:

(mkRemovedOptionModule [ "services" "phpfpm" "phpOptions" ] "Use services.phpfpm.pools.<name>.phpOptions instead.")

I'll state that this PR should not be merged, in my opinion, because it is based on a PR I'm planning to revert with 63931. Note that #63931 will reintroduce the ability to set phpOptions globally which is half of what this PR does.

As an aside @Izorkin what is your use case for using a tcp connection instead of a unix socket? I'm curious because one has much better performance than the other.

@Izorkin
Copy link
Contributor Author

Izorkin commented Jul 1, 2019

@aanderse globalPhpOptions allows you to set global parameters.
Example config with tcp connection:

  services.phpfpm = {
    globalExtraConfig = ''
      rlimit_files = 131072
      rlimit_core = unlimited
    '';
    globalPhpOptions = ''
      display_errors = off
      display_startup_errors = off
      open_basedir = /dev/urandom:/proc/cpuinfo:/proc/meminfo:/etc/ssl/certs:/var/www
      disable_functions = exec,passthru,shell_exec,system
      date.timezone = "Europe/Moscow"
    '';
    pools = {
      "example-php72" = {
        listenTCP = "127.0.0.1:9002";
        phpPackage = pkgs.php72;
        user = "nginx";
        group = "nginx";
        phpOptions = ''
          ; Extensions
          extension = ${pkgs.php72Packages.apcu}/lib/php/extensions/apcu.so
          extension = ${pkgs.php72Packages.imagick}/lib/php/extensions/imagick.so
          extension = ${pkgs.php72Packages.memcached}/lib/php/extensions/memcached.so
          extension = ${pkgs.php72Packages.event}/lib/php/extensions/event.so
          zend_extension = ${pkgs.php72}/lib/php/extensions/opcache.so
        '';
        extraConfig = ''
          pm = dynamic
          pm.max_children = 40
          pm.start_servers = 4
          pm.min_spare_servers = 4
          pm.max_spare_servers = 12
          pm.max_requests = 500
          listen.backlog = 65536
          security.limit_extensions = .php
        '';
      };
    };
  };

@aanderse
Copy link
Member

aanderse commented Jul 1, 2019

@Izorkin Setting global php options is what you removed from your last PR. Now you are adding it back.

I understand how to use tcp connection I'm just curious why you would do that when socket is faster. What benefit do you get from using tcp instead of socket in this example?

@Izorkin
Copy link
Contributor Author

Izorkin commented Jul 1, 2019

Yes, I missed the moment with the global php.ini configuration.
It is possible that someone else is using tcp connection with option c listen = "127.0.0.1:9000"; In this case, it remains possible to use tcp connection.

@aanderse
Copy link
Member

aanderse commented Jul 3, 2019

Closing in favor of #63931

@aanderse aanderse closed this Jul 3, 2019
@Izorkin Izorkin deleted the phpfpmOptions branch August 14, 2019 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants