Guide on running these versions with apache (mod php)
Any idea on how we could use these old php version (5.5) on apache
Hi !
AFAIK, we don't maintain 5.5, we start at 5.6.
Hi !
AFAIK, we don't maintain 5.5, we start at 5.6.
Ok, 5.6 is also fine for us.
First you need to add the overlay of this flake in your own configuration.
In the whole process, this is probably the most complex part. An overlay is just the default standard mechanism to extends pkgs in Nix by adding a layer on top of your configuration so that when you do pkgs.php56, it works.
Then, once it's done, a quick search on Google led me to https://nixos.wiki/wiki/PHP, where I can see a snippet related to Apache.
You would just need to replace pkgs.php with pkgs.php56 and it should be good to go.
First you need to add the overlay of this flake in your own configuration.
In the whole process, this is probably the most complex part. An overlay is just the default standard mechanism to extends
pkgsin Nix by adding a layer on top of your configuration so that when you dopkgs.php56, it works.Then, once it's done, a quick search on Google led me to https://nixos.wiki/wiki/PHP, where I can see a snippet related to Apache.
You would just need to replace
pkgs.phpwithpkgs.php56and it should be good to go.
Could I point an ubuntu installed apache server to use this nix php binary (maybe by just hardcoding the path in nix store)
Technically it should work, but using raw /nix/store/... paths is a bad practice since it can be garbage collected.
I would simply recommend you to add it to your profile using nix profile so now your can be sure that it will never be GC'd.
❯ nix profile install github:fossar/nix-phps#php56
❯ php -v
PHP 5.6.40 (cli) (built: Jan 9 2019 10:25:59)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
❯ type php
php is /home/pol/.nix-profile/bin/php
❯
Technically it should work, but using raw
/nix/store/...paths is a bad practice since it can be garbage collected. I would simply recommend you to add it to your profile usingnix profileso now your can be sure that it will never be GC'd.❯ nix profile install github:fossar/nix-phps#php56 ❯ php -v PHP 5.6.40 (cli) (built: Jan 9 2019 10:25:59) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies ❯ type php php is /home/pol/.nix-profile/bin/php ❯
Perfect, so apache would just call nix php automatically since it's on the path
If there are no other php on your system and if the user running apache is the same user who run nix profile, yes.
If there are no other
phpon your system and if the user running apache is the same user who runnix profile, yes.
Seems like mod-php embeds php within apache, and doesn't call cli process at all, so this idea wouldn't work
In theory, it should be possible but unless Apache has stable ABI for modules, you would probably also need to ensure that the PHP is linked against the same version of Apache as the one you are running (and possibly other parameters).
I think at that point it would be easier to replace the Ubuntu’s Apache with a one from Nixpkgs.
In theory, it should be possible but unless Apache has stable ABI for modules, you would probably also need to ensure that the PHP is linked against the same version of Apache as the one you are running (and possibly other parameters).
I think at that point it would be easier to replace the Ubuntu’s Apache with a one from Nixpkgs.
Yes but does nixpkgs apache have older versions of mod-php?
No. But that is what this repo is for.
No. But that is what this repo is for.
Ok, so older modphp versions can be added to this flake?
If you want to to run Apache from Nix, you are best off looking at the relevant NixOS module. For example, this is how you get PHP with mod_php:
https://github.com/NixOS/nixpkgs/blob/8a3e1cf40a6eaeb122c8321b97a0518cfa6ed779/nixos/modules/services/web-servers/apache-httpd/default.nix#L21
If you want to to run Apache from Nix, you are best off looking at the relevant NixOS module. For example, this is how you get PHP with
mod_php:https://github.com/NixOS/nixpkgs/blob/8a3e1cf40a6eaeb122c8321b97a0518cfa6ed779/nixos/modules/services/web-servers/apache-httpd/default.nix#L21
Yes, but can i replace the php version in them to older ones like 5.6
Sure, just do as mentioned above https://github.com/fossar/nix-phps/issues/325#issuecomment-1934387999
Sure, just do as mentioned above #325 (comment)
I'm yet to try this overlays approach, it would be handier if it was prepackaged in this flake itself, basically I'm imagining this flake to be a simple way to maintain legacy versions of our software, we are also exploring lxd containers in this space.
You do not need the overlays approach but it the simplest way to use this flake. Or at least with fewest caveats – you could just use the packages.${system}.php output of the flake directly, but then you would need to make sure the Nixpkgs revision is the same as the one used to built PHP in this flake.
We are not going to include Apache in this flake, that just does not compose.
i don't think what has been discussed in this issue is really the biggest challenge with what @aszenz is attempting to do - generating a configuration file for apache and running the software is going to be the biggest challenge when attempting to run a nix provided apache+php on ubuntu, in my opinion
so how can @aszenz proceed? personally i would suggest using system-manager as it would make running older php versions with apache on ubuntu relatively easy compared to other options
i was able to get the latest version of apache running php version 5.6 on ubuntu in just a few minutes from scratch with the following configuration:
{ nixosModulesPath, config, pkgs, lib, ... }:
{
imports = [
"${nixosModulesPath}/services/web-servers/apache-httpd"
./compat.nix
];
nixpkgs.hostPlatform = "x86_64-linux";
services.httpd = {
enable = true;
enablePHP = true;
user = "www-data";
group = "www-data";
phpPackage = pkgs.php56;
virtualHosts."localhost" = {
documentRoot = "/srv/www";
};
};
}
@aszenz if you're interested in exploring this option further i would be happy to provide additional details for you
i don't think what has been discussed in this issue is really the biggest challenge with what @aszenz is attempting to do - generating a configuration file for
apacheand running the software is going to be the biggest challenge when attempting to run anixprovidedapache+phpon ubuntu, in my opinionso how can @aszenz proceed? personally i would suggest using system-manager as it would make running older
phpversions withapacheon ubuntu relatively easy compared to other optionsi was able to get the latest version of
apacherunningphpversion5.6on ubuntu in just a few minutes from scratch with the following configuration:{ nixosModulesPath, config, pkgs, lib, ... }: { imports = [ "${nixosModulesPath}/services/web-servers/apache-httpd" ./compat.nix ]; nixpkgs.hostPlatform = "x86_64-linux"; services.httpd = { enable = true; enablePHP = true; user = "www-data"; group = "www-data"; phpPackage = pkgs.php56; virtualHosts."localhost" = { documentRoot = "/srv/www"; }; }; }@aszenz if you're interested in exploring this option further i would be happy to provide additional details for you
Thanks, i tried this on my own nixos system (the server will be ubuntu though) and got this error:
getting status of '/nix/store/jp2kw74bigwv1npgi02n22hqm7dj7r6f-source/compat.nix': No such file or directory
i don't think what has been discussed in this issue is really the biggest challenge with what @aszenz is attempting to do - generating a configuration file for
apacheand running the software is going to be the biggest challenge when attempting to run anixprovidedapache+phpon ubuntu, in my opinionso how can @aszenz proceed? personally i would suggest using system-manager as it would make running older
phpversions withapacheon ubuntu relatively easy compared to other optionsi was able to get the latest version of
apacherunningphpversion5.6on ubuntu in just a few minutes from scratch with the following configuration:{ nixosModulesPath, config, pkgs, lib, ... }: { imports = [ "${nixosModulesPath}/services/web-servers/apache-httpd" ./compat.nix ]; nixpkgs.hostPlatform = "x86_64-linux"; services.httpd = { enable = true; enablePHP = true; user = "www-data"; group = "www-data"; phpPackage = pkgs.php56; virtualHosts."localhost" = { documentRoot = "/srv/www"; }; }; }@aszenz if you're interested in exploring this option further i would be happy to provide additional details for you
Thanks i created https://github.com/numtide/system-manager/issues/72, initially tested it on NixOS before i can test it on Ubuntu server
as mentioned - if you're interested in exploring this option further i would be happy to provide additional details for you
i did not include all details so please close that ticket against system-manager - there is no problem there, the problem is that you don't have all the source
i pushed the source here so you can take a look and have a fully running example
@aszenz i missed the part where you said you were testing on NixOS instead of Ubuntu, sorry.
Did my example help at all? Did you get what you needed?