0

I'm trying to setup an LAMP environment with NixOs. I managed to have mysql and apache running, but I can't find a way to enable php. At the moment, apache is serving php file as text instead of executing it.

I've seen there is a enablePHP option in the appache-httpd/default.nix file but it doesn't seem visible (it doesn't appear when I do man configuration.nix and I get an error message if I try to set it to true).

mb14
  • 22,276
  • 7
  • 60
  • 102

2 Answers2

1

Most likely the version of nixpkgs used to build your system (and the configuration.nix man page) is older than the version of nixpkgs you are looking at. After an update of your system the option should be documented in the configuration.nix man page and work as expected.

I successfully use enablePHP and enableUserDir to render php files in my user's public_html. An .htaccess file with DirectoryIndex index.php further enables php index files.

0

I'm also in the process of setting up a php stack (using nginx / php-fpm) and I found the following, which might answer your question. Use the extraModules parameter of the httpd config to enable the php module, like so:

  extraModules = [
    { name = "php5"; path = "${pkgs.php}/modules/libphp5.so"; }
  ];

I found this example here: https://github.com/svanderburg/disnix-stafftracker-php-example/blob/master/deployment/configurations/test-vm1-httpd.nix

4levels
  • 3,134
  • 1
  • 23
  • 22