mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-01 19:33:03 +00:00
* Option `services.apache.phpIni' (which is of type derivation)
replaced by `services.apache.phpOptions' (of type string). * Allow Apache subservices to add to phpOptions. * Set the TZ environment variable in Apache. * Updated the Zabbix web interface. svn path=/nixos/trunk/; revision=20023
This commit is contained in:
parent
014ffaac5d
commit
83b76bc2cf
@ -45,6 +45,8 @@ in
|
|||||||
|
|
||||||
config = mkIf config.services.zabbixServer.enable {
|
config = mkIf config.services.zabbixServer.enable {
|
||||||
|
|
||||||
|
services.postgresql.enable = true;
|
||||||
|
|
||||||
users.extraUsers = singleton
|
users.extraUsers = singleton
|
||||||
{ name = "zabbix";
|
{ name = "zabbix";
|
||||||
uid = config.ids.uids.zabbix;
|
uid = config.ids.uids.zabbix;
|
||||||
@ -52,7 +54,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
jobs.zabbix_server =
|
jobs.zabbix_server =
|
||||||
{ #name = "zabbix-server"; !!! mkIf bug
|
{ name = "zabbix-server";
|
||||||
|
|
||||||
description = "Zabbix server daemon";
|
description = "Zabbix server daemon";
|
||||||
|
|
||||||
@ -67,18 +69,21 @@ in
|
|||||||
if ! test -e "${libDir}/db-created"; then
|
if ! test -e "${libDir}/db-created"; then
|
||||||
${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole zabbix || true
|
${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole zabbix || true
|
||||||
${pkgs.postgresql}/bin/createdb --owner zabbix zabbix || true
|
${pkgs.postgresql}/bin/createdb --owner zabbix zabbix || true
|
||||||
cat ${pkgs.zabbixServer}/share/zabbix/db/schema/postgresql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
|
cat ${pkgs.zabbix.server}/share/zabbix/db/schema/postgresql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c '${pkgs.postgresql}/bin/psql zabbix'
|
||||||
cat ${pkgs.zabbixServer}/share/zabbix/db/data/data.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
|
cat ${pkgs.zabbix.server}/share/zabbix/db/data/data.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c '${pkgs.postgresql}/bin/psql zabbix'
|
||||||
cat ${pkgs.zabbixServer}/share/zabbix/db/data/images_pgsql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
|
cat ${pkgs.zabbix.server}/share/zabbix/db/data/images_pgsql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c '${pkgs.postgresql}/bin/psql zabbix'
|
||||||
touch "${libDir}/db-created"
|
touch "${libDir}/db-created"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PATH=${pkgs.nettools}/bin:$PATH
|
export PATH=${pkgs.nettools}/bin:$PATH
|
||||||
${pkgs.zabbixServer}/sbin/zabbix_server --config ${configFile}
|
${pkgs.zabbix.server}/sbin/zabbix_server --config ${configFile}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postStop =
|
postStop =
|
||||||
''
|
''
|
||||||
|
pid=$(cat ${pidFile})
|
||||||
|
test -n "$pid" && kill "$pid"
|
||||||
|
# Wait until they're really gone.
|
||||||
while ${pkgs.procps}/bin/pkill -u zabbix zabbix_server; do true; done
|
while ${pkgs.procps}/bin/pkill -u zabbix zabbix_server; do true; done
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -68,6 +68,7 @@ let
|
|||||||
globalEnvVars = [];
|
globalEnvVars = [];
|
||||||
robotsEntries = "";
|
robotsEntries = "";
|
||||||
startupScript = "";
|
startupScript = "";
|
||||||
|
phpOptions = "";
|
||||||
options = {};
|
options = {};
|
||||||
};
|
};
|
||||||
res = defaults // svcFunction {inherit config pkgs serverInfo servicesPath;};
|
res = defaults // svcFunction {inherit config pkgs serverInfo servicesPath;};
|
||||||
@ -358,7 +359,18 @@ let
|
|||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
||||||
|
# Generate the PHP configuration file. Should probably be factored
|
||||||
|
# out into a separate module.
|
||||||
|
phpIni = pkgs.runCommand "php.ini"
|
||||||
|
{ options = concatStringsSep "\n"
|
||||||
|
([ mainCfg.phpOptions ] ++ (map (svc: svc.phpOptions) allSubservices));
|
||||||
|
}
|
||||||
|
''
|
||||||
|
cat ${pkgs.php}/etc/php-recommended.ini > $out
|
||||||
|
echo "$options" >> $out
|
||||||
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
||||||
@ -464,54 +476,14 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
phpIni = mkOption {
|
phpOptions = mkOption {
|
||||||
default = pkgs.writeText "php.ini" ''
|
default = "";
|
||||||
; Needed for PHP's mail() function.
|
example =
|
||||||
sendmail_path = sendmail -t -i
|
''
|
||||||
'';
|
date.timezone = "CET"
|
||||||
|
'';
|
||||||
example = ''
|
description =
|
||||||
Example code (copy & paste):
|
"Options appended to the PHP configuration file <filename>php.ini</filename>.";
|
||||||
|
|
||||||
most simple:
|
|
||||||
phpIni pkgs.writeText "php.ini" '''
|
|
||||||
; Needed for PHP's mail() function.
|
|
||||||
sendmail_path = sendmail -t -i
|
|
||||||
''';
|
|
||||||
|
|
||||||
using recommended settings and enabling Xdebug:
|
|
||||||
phpIni = pkgs.phpIniBuilder.override {
|
|
||||||
appendLines = '''
|
|
||||||
sendmail_path = sendmail -t -i
|
|
||||||
zend_extension="''\${pkgs.phpXdebug}/lib/xdebug.so"
|
|
||||||
zend_extension_ts="''\${pkgs.phpXdebug}/lib/xdebug.so"
|
|
||||||
zend_extension_debug="''\${pkgs.phpXdebug}/lib/xdebug.so"
|
|
||||||
xdebug.remote_enable=true
|
|
||||||
xdebug.remote_host=127.0.0.1
|
|
||||||
xdebug.remote_port=9000
|
|
||||||
xdebug.remote_handler=dbgp
|
|
||||||
xdebug.profiler_enable=0
|
|
||||||
xdebug.profiler_output_dir="/tmp/xdebug"
|
|
||||||
xdebug.remote_mode=req
|
|
||||||
''';
|
|
||||||
};
|
|
||||||
'';
|
|
||||||
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
The contents of this option are used as global php.ini file by the
|
|
||||||
PHP interpreter used by Apache. You have to enable PHP explicitly.
|
|
||||||
See extraModules options.
|
|
||||||
|
|
||||||
This file defaults to defining sendmail_path only.
|
|
||||||
|
|
||||||
Note: Depending on your configuration you can set PHP ini values using .htaccess files and the
|
|
||||||
php_value option.
|
|
||||||
|
|
||||||
The example shows how to enable Xdebug and use the recommended
|
|
||||||
php.ini values which are contained in the PHP distribution.
|
|
||||||
I don't know whether they are equal to defaults
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -540,6 +512,15 @@ in
|
|||||||
|
|
||||||
environment.systemPackages = [httpd] ++ concatMap (svc: svc.extraPath) allSubservices;
|
environment.systemPackages = [httpd] ++ concatMap (svc: svc.extraPath) allSubservices;
|
||||||
|
|
||||||
|
services.httpd.phpOptions =
|
||||||
|
''
|
||||||
|
; Needed for PHP's mail() function.
|
||||||
|
sendmail_path = sendmail -t -i
|
||||||
|
|
||||||
|
; Apparently PHP doesn't use $TZ.
|
||||||
|
date.timezone = "${config.time.timeZone}"
|
||||||
|
'';
|
||||||
|
|
||||||
jobs.httpd =
|
jobs.httpd =
|
||||||
{ # Statically verify the syntactic correctness of the generated
|
{ # Statically verify the syntactic correctness of the generated
|
||||||
# httpd.conf. !!! this is impure! It doesn't just check for
|
# httpd.conf. !!! this is impure! It doesn't just check for
|
||||||
@ -570,7 +551,9 @@ in
|
|||||||
optional config.networking.defaultMailServer.directDelivery "${pkgs.ssmtp}/sbin"
|
optional config.networking.defaultMailServer.directDelivery "${pkgs.ssmtp}/sbin"
|
||||||
++ (concatMap (svc: svc.extraServerPath) allSubservices) );
|
++ (concatMap (svc: svc.extraServerPath) allSubservices) );
|
||||||
|
|
||||||
PHPRC = mainCfg.phpIni;
|
PHPRC = phpIni;
|
||||||
|
|
||||||
|
TZ = config.time.timeZone;
|
||||||
|
|
||||||
} // (listToAttrs (concatMap (svc: svc.globalEnvVars) allSubservices));
|
} // (listToAttrs (concatMap (svc: svc.globalEnvVars) allSubservices));
|
||||||
|
|
||||||
@ -606,4 +589,3 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,23 +9,27 @@ let
|
|||||||
# Note that different instances of the frontend will therefore end
|
# Note that different instances of the frontend will therefore end
|
||||||
# up with their own copies of the PHP sources. !!! Alternatively,
|
# up with their own copies of the PHP sources. !!! Alternatively,
|
||||||
# we could generate zabbix.conf.php declaratively.
|
# we could generate zabbix.conf.php declaratively.
|
||||||
zabbixPHP = pkgs.runCommand "${pkgs.zabbixServer.name}-php" {} ''
|
zabbixPHP = pkgs.runCommand "${pkgs.zabbix.server.name}-php" {}
|
||||||
cp -rs ${pkgs.zabbixServer}/share/zabbix/php $out
|
''
|
||||||
chmod -R u+w $out
|
cp -rs ${pkgs.zabbix.server}/share/zabbix/php $out
|
||||||
#rm -rf $out/conf
|
chmod -R u+w $out
|
||||||
ln -s ${config.stateDir}/zabbix.conf.php $out/conf/zabbix.conf.php
|
#rm -rf $out/conf
|
||||||
'';
|
ln -s ${config.stateDir}/zabbix.conf.php $out/conf/zabbix.conf.php
|
||||||
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
extraModules = [
|
extraModules =
|
||||||
{ name = "php5"; path = "${pkgs.php}/modules/libphp5.so"; }
|
[ { name = "php5"; path = "${pkgs.php}/modules/libphp5.so"; } ];
|
||||||
];
|
|
||||||
|
|
||||||
# !!! should also declare PHP options that Zabbix needs like the
|
phpOptions =
|
||||||
# timezone and timeout.
|
''
|
||||||
|
post_max_size = 32M
|
||||||
|
max_execution_time = 300
|
||||||
|
mbstring.func_overload = 2
|
||||||
|
'';
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
Alias ${config.urlPrefix}/ ${zabbixPHP}/
|
Alias ${config.urlPrefix}/ ${zabbixPHP}/
|
||||||
|
Loading…
Reference in New Issue
Block a user