Add php option to the Apache HTTPD service

This commit is contained in:
Sander van der Burg 2020-04-17 20:02:30 +02:00 committed by Sander van der Burg
parent df036873ab
commit aadbc7fd62
3 changed files with 17 additions and 4 deletions

View File

@ -21,7 +21,7 @@ in
simple-webapp-apache = import ./simple-webapp-apache.nix {
inherit createManagedProcess logDir runtimeDir forceDisableUserChange;
inherit (pkgs) stdenv apacheHttpd writeTextFile;
inherit (pkgs) stdenv apacheHttpd php writeTextFile;
};
mysql = import ./mysql.nix {

View File

@ -1,5 +1,5 @@
{createManagedProcess, stdenv, apacheHttpd, writeTextFile, logDir, runtimeDir, forceDisableUserChange}:
{instanceSuffix ? "", port ? 80, modules ? [], serverName ? "localhost", serverAdmin, documentRoot ? ./webapp, extraConfig ? "", postInstall ? ""}:
{createManagedProcess, stdenv, apacheHttpd, php, writeTextFile, logDir, runtimeDir, forceDisableUserChange}:
{instanceSuffix ? "", port ? 80, modules ? [], serverName ? "localhost", serverAdmin, documentRoot ? ./webapp, enablePHP ? false, extraConfig ? "", postInstall ? ""}:
let
instanceName = "httpd${instanceSuffix}";
@ -76,11 +76,24 @@ import ./apache.nix {
${stdenv.lib.concatMapStrings (module: ''
LoadModule ${module.name}_module ${module.module}
'') modules}
${stdenv.lib.optionalString enablePHP ''
LoadModule php7_module ${php}/modules/libphp7.so
''}
ServerAdmin ${serverAdmin}
DocumentRoot "${documentRoot}"
${stdenv.lib.optionalString enablePHP ''
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
<Directory ${documentRoot}>
DirectoryIndex index.php
</Directory>
''}
${extraConfig}
'';
};

View File

@ -9,7 +9,7 @@ let
pidFile = "${runtimeDir}/${instanceName}.pid";
in
createManagedProcess rec {
name = "tomcat";
name = instanceName;
inherit instanceName user pidFile postInstall;
process = "${tomcat}/bin/catalina.sh";