Created
April 10, 2025 20:07
-
-
Save entropie/9705b2ea9d78e3af14ee69ae57d0fb56 to your computer and use it in GitHub Desktop.
phpbb on nixos - dont ask
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, lib, ... }: | |
let | |
domain = "localhost"; | |
dataDir = "/srv/phpbb"; | |
app = "phpbb"; | |
in { | |
services.mysql = { | |
enable = true; | |
package = pkgs.mariadb; | |
}; | |
services.mysql.ensureUsers = [{ | |
name = "phpbb"; | |
ensurePermissions = { | |
"phpbb.*" = "ALL PRIVILEGES"; | |
}; | |
}]; | |
users.users.${app} = { | |
isSystemUser = true; | |
home = dataDir; | |
group = app; | |
extraGroups = [ "http" ]; | |
}; | |
users.groups.http = {}; | |
users.groups.${app} = {}; | |
services.phpfpm.pools.${app} = { | |
user = app; | |
group = app; | |
settings = { | |
"listen.owner" = config.services.nginx.user; | |
"listen.group" = config.services.nginx.group; | |
"listen.mode" = "0600"; | |
"pm" = "dynamic"; | |
"pm.max_children" = 10; | |
"pm.start_servers" = 2; | |
"pm.min_spare_servers" = 1; | |
"pm.max_spare_servers" = 5; | |
"php_admin_value[error_log]" = "stderr"; | |
"php_admin_flag[log_errors]" = true; | |
"catch_workers_output" = true; | |
}; | |
phpEnv."PATH" = lib.makeBinPath [ pkgs.php ]; | |
}; | |
services.nginx = { | |
enable = true; | |
virtualHosts.${domain} = { | |
root = dataDir; | |
locations = { | |
"/" = { | |
extraConfig = '' | |
index index.php index.html index.htm; | |
''; | |
tryFiles = "$uri $uri/ @rewriteapp"; | |
}; | |
"~ \\.php($|/)" = { | |
extraConfig = '' | |
include ${pkgs.nginx}/conf/fastcgi.conf; | |
fastcgi_split_path_info ^(.+\\.php)(/.*)$; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param DOCUMENT_ROOT $document_root; | |
fastcgi_pass unix:${config.services.phpfpm.pools.${app}.socket}; | |
''; | |
}; | |
"@rewriteapp" = { | |
extraConfig = '' | |
rewrite ^(.*)$ /app.php/$1 last; | |
''; | |
}; | |
"~ /(config\\.php|common\\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb(?!\\w+)|store|vendor)" = { | |
extraConfig = '' | |
deny all; | |
internal; | |
''; | |
}; | |
"~ /(\\.svn|\\.git)" = { | |
extraConfig = '' | |
deny all; | |
internal; | |
''; | |
}; | |
"/install/" = { | |
tryFiles = "$uri $uri/ @rewrite_installapp =404"; | |
}; | |
"@rewrite_installapp" = { | |
extraConfig = '' | |
rewrite ^(.*)$ /install/app.php/$1 last; | |
''; | |
}; | |
}; | |
}; | |
}; | |
# environment.systemPackages = with pkgs; [ | |
# ]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment