-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: John Titor <[email protected]>
- Loading branch information
1 parent
d6a66f9
commit b57a91a
Showing
1 changed file
with
44 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,53 @@ | ||
{ | ||
config, | ||
pkgs, | ||
lib, | ||
userSettings, | ||
pkgs, | ||
... | ||
}: { | ||
services.nginx = { | ||
enable = true; | ||
virtualHosts.localhost = { | ||
locations."/wiki" = { | ||
return = "200 '<html><body>It works<br><?php phpinfo();></body></html>'"; | ||
extraConfig = '' | ||
default_type text/html; | ||
''; | ||
}; | ||
services.nginx.enable = true; | ||
|
||
# Nginx virtual host configuration for localhost | ||
services.nginx.virtualHosts."localhost" = { | ||
root = "/var/www/phptest"; | ||
extraConfig = '' | ||
index index.php; | ||
''; | ||
|
||
locations."~ ^(.+\\.php)(.*)$" = { | ||
extraConfig = '' | ||
# Check that the PHP script exists before passing it | ||
try_files $fastcgi_script_name =404; | ||
include ${config.services.nginx.package}/conf/fastcgi_params; | ||
fastcgi_split_path_info ^(.+\.php)(.*)$; | ||
fastcgi_pass unix:${config.services.phpfpm.pools.mypool.socket}; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
include ${pkgs.nginx}/conf/fastcgi.conf; | ||
''; | ||
}; | ||
}; | ||
|
||
environment.systemPackages = [ pkgs.php ]; | ||
# MySQL service | ||
services.mysql = { | ||
enable = true; | ||
package = pkgs.mariadb; | ||
}; | ||
|
||
# PHP-FPM pool configuration | ||
# Needed for nginx to communicate with PHP | ||
services.phpfpm.pools.mypool = { | ||
user = "nobody"; | ||
settings = { | ||
"pm" = "dynamic"; | ||
"listen.owner" = config.services.nginx.user; | ||
"listen.group" = config.services.nginx.group; | ||
"pm.max_children" = 5; | ||
"pm.start_servers" = 2; | ||
"pm.min_spare_servers" = 1; | ||
"pm.max_spare_servers" = 3; | ||
"pm.max_requests" = 500; | ||
}; | ||
phpEnv."PATH" = lib.makeBinPath [ pkgs.php ]; | ||
}; | ||
} |