Phpfpm
php-fpm is a fastcgi interface for php.
Configuration for nginx
This configuration will set up phpfpm for serving php files from /var/www/example.com
.
put into your configuration.nix
<syntaxHighlight lang=nix>
{
services.phpfpm.poolConfigs."example.com" = listen = /var/run/example.com-phpfpm.sock user = nginx group = nginx pm = dynamic pm.max_children = 32 pm.max_requests = 500 pm.start_servers = 2 pm.min_spare_servers = 2 pm.max_spare_servers = 5 listen.owner = nginx listen.group = nginx php_admin_value[error_log] = 'stderr' php_admin_flag[log_errors] = on env[PATH] = ${lib.makeBinPath [ pkgs.php ]} catch_workers_output = yes ; services.nginx = { enable = true; virtualHosts."example.com".locations."/" = { root = "/var/www/example.com"; extraConfig = fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/example.com-phpfpm.sock; include ${pkgs.nginx}/conf/fastcgi_params; include ${pkgs.nginx}/conf/fastcgi.conf; ; }; }; };
} </syntaxHightlight>
PHP Extensions
To use certain PHP extensions you will need to configure them in the php.ini
-configuration of phpfpm:
<syntaxHightlight lang=nix>
{
services.phpfpm.phpOptions = extension=${pkgs.phpPackages.redis}/lib/php/extensions/redis.so extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so ;
} </syntaxHightlight>