well…the title tell everything…please tell how to add sqlsrv driver for php? thank you…
You can find PHP extensions here:
And you can get PHP with any extension as described here:
https://nixos.org/manual/nixpkgs/unstable/#ssec-php-user-guide-installing-with-extensions
help me litle bit more please i use the example from that link and whern i run nixos-rebuild, the error said undefined variable “php”, what should i do? sorry…i’m newbie…
this is my config look like
{ pkgs, config, ... }:
let
myPhp = php.buildEnv {
extensions = { all, ... }: with all; [ sqlsrv pdo_sqlsrv ];
extraConfig = "memory_limit=256M";
};
in {
services.phpfpm.pools."myPool".phpPackage = myPhp;
services.httpd =
{
user = "fadhli";
enable = true;
adminAddr = "localhost";
extraModules =
[
"http2"
];
enablePHP = true;
virtualHosts =
{
localhost = {
documentRoot = "/home/fadhli/www";
};
};
};
}
Hi @paklie! To directly address your question, you want to write pkgs.php
instead of php
, as in:
myPhp = pkgs.php.buildEnv {
extensions = { all, ... }: with all; [ sqlsrv pdo_sqlsrv ];
extraConfig = "memory_limit=256M";
};
There are a few other issues we should address first, though:
- there are 2 separate ways for the
httpd
web server to executephp
scripts: viamod_php
(which corresponds toservices.httpd.enablePHP = true;
orphp-fpm
(which corresponds toservices.phpfpm
) - you should only choose one or the other - if you want to continue with
mod_php
instead ofphp-fpm
then you should setservices.httpd.phpPackage = myPhp;
, though I would encourage you to usephp-fpm
instead - you don’t need to include
"http2"
inextraModules
because NixOS will already include it
If you need any help/review/advice on your configuration.nix
please feel free to provide a link to it and could take a look.
ahhhhh…now its working…thankyou sooooo much for your help i learn something today by your advice…actualy i’m very new using nixos… my nixos is still fress instal with default configuration…what i trying to do is instal apache, php, sql server stack on my nixos…i already succeeded in bringin sqlserver trough docker but strugle in enabling phpfpm on apache with sqlsrv extention…but now everthing is working fine, only a tttiiiiiiiiiiiiny litle bit more if you can help me again…
when i access my virtual host, it list the derictory not execute the index.php file by default…after i click the index.php file than it run my site…how to make it execute index.php file by default???
You want something like this:
services.httpd.virtualHosts.localhost = {
documentRoot = "/home/fadhli/www";
extraConfig = ''
<Directory /home/fadhli/www>
DirectoryIndex index.php
</Directory>
'';
};
See mod_dir - Apache HTTP Server Version 2.4 for details.
perfect…!!! thank you soo much