New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
php: build embedded, uwsgi: enable php plugin #19139
Conversation
@schneefux, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @abbradar and @dezgeg to be potential reviewers. |
@@ -228,6 +232,7 @@ let | |||
pdo_mysqlSupport = config.php.pdo_mysql or true; | |||
libxml2Support = config.php.libxml2 or true; | |||
apxs2Support = config.php.apxs2 or (!stdenv.isDarwin); | |||
embedSupport = config.php.embed or false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be true
as default so there would be no need for another top-level php attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Only one SAPI can be built at a time, either "apxs2" or "embed" in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could assure with an assert, that either one or the other option is used? You could also add one option which is either set either to apxs2 or embed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that needed? When compiling with both flags, php shows this message:
checking for embedded SAPI library support... configure: error:
+--------------------------------------------------------------------+
| *** ATTENTION *** |
| |
| You've configured multiple SAPIs to be build. You can build only |
| one SAPI module plus CGI, CLI and FPM binaries at the same time. |
+--------------------------------------------------------------------+
I think that's sufficient - maybe it will be possible to build multiple SAPIs in future PHP versions.
--replace '@CONFIGURE_OPTIONS@' "" \ | ||
--replace '@PHP_LDFLAGS@' "" | ||
done | ||
fi | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ${if (config.php.embed or false) == false then "true" else "false"}; then
can be all done in nix, eg:
${optionalString config.php.embed ''...''}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That gives me attribute php missing
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use (config.php.embed or false)
.
@@ -74,7 +79,7 @@ stdenv.mkDerivation rec { | |||
buildPhase = '' | |||
mkdir -p $pluginDir | |||
python3 uwsgiconfig.py --build nixos | |||
${lib.concatMapStringsSep ";" (x: "${x.interpreter or "python3"} uwsgiconfig.py --plugin ${x.path} nixos ${x.name}") needed} | |||
${lib.concatMapStringsSep ";" (x: "${x.preBuild or ""} ${x.interpreter or "python3"} uwsgiconfig.py --plugin ${x.path} nixos ${x.name}") needed} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a semicolon after preBuild
here so that we wouldn't need to add it in every preBuild
by hand. You can fallback to true
so that if preBuild
is not set it evaluates to true;
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, even better -- use a "\n", then you don't need tricks with true
,
82fc009
to
85bf33a
Compare
@abbradar @ericsagnes I updated the PR with your changes. |
@schneefux Enable sandboxing -- this would most likely allow you to reproduce. |
@@ -4,7 +4,8 @@ | |||
, pam, withPAM ? false | |||
, systemd, withSystemd ? false | |||
, python2, python3, ncurses | |||
, ruby | |||
, ruby, php-embed | |||
, openldap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openldap is not used.
can you add your php example to |
I got the example from the official documentation, I added a link. |
Any chance this gets merged? |
@bachp can you provide me a configuration to test uwsgi + php. Just something which shows that plugin gets initialized. |
services.nginx = {
enable = true;
virtualHosts = {
"example.com" = {
root = "/var/www";
locations."/".extraConfig = ''
include ${pkgs.nginx}/conf/uwsgi_params;
uwsgi_modifier1 14;
uwsgi_pass unix:${config.services.uwsgi.instance.vassals.php.socket};
'';
};
};
};
services.uwsgi = {
enable = true;
user = "nginx";
group = "nginx";
instance = {
type = "emperor";
vassals = {
php = {
type = "normal";
socket = "/run/uwsgi/php.sock";
master = true;
vacuum = true;
processes = 4;
cheaper = 1;
php-sapi-name = "apache"; # performance tweak
socket-modifier1 = 14;
php-index = "index.php";
php-set = [ "session.save_handler=files" "session.save_path=/var/www/sessions" ]; # fixes session issues with Nextcloud
plugins = [ "php" ];
};
};
};
plugins = [ "php" ];
}; index.php: <?php phpinfo(); ?> |
Allows to run uwsgi with the PHP plugin.
The plugin needs embedded PHP, so I added php70-embed. (@globin)
Usage example:
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)