Skip to content

Instantly share code, notes, and snippets.

@chrisfarms
Created June 2, 2014 20:07
Show Gist options
  • Save chrisfarms/6fe85f04b0e349ff60a3 to your computer and use it in GitHub Desktop.
Save chrisfarms/6fe85f04b0e349ff60a3 to your computer and use it in GitHub Desktop.
Sketchy LAMP
{ config, pkgs, ... }:
let
srcDir = builtins.toString ./.;
dataDir = "/var/data/";
mysqlpass = "v3rys3cr3t";
in {
system.activationScripts.uploadsDir = ''
mkdir -p "${dataDir}"
chown -R wwwrun:wwwrun "${dataDir}"
'';
networking.firewall.allowedTCPPorts = [ 80 443 ];
services.httpd = {
enable = true;
phpOptions = ''
short_open_tag=On
'';
virtualHosts = [{
hostName = "*";
documentRoot = "${srcDir}";
extraConfig = ''
SetEnv RES_DATABASE "mysql://root:${mysqlpass}@localhost/mydatabase"
SetEnv RES_DATA_DIR "${dataDir}"
<Directory "${srcDir}">
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
Alias /library ${dataDir}
<Directory "${dataDir}">
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
'';
}];
};
services.mysql = {
enable = true;
package = pkgs.mysql55;
rootPassword = pkgs.writeTextFile { name = "mysqlpw"; text = mysqlpass; };
initialDatabases = [{
name = "mydatabase";
schema = ./init.mysql;
}];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment