Set "AllowOverride All" in Apache's httpd.conf

I want to setup Apache webserver for a Magento project in NixOS and have this expression in configuration.nix:

services.httpd = {
enable =true;
enablePHP =true;
phpPackage = myPHP;
extraModules = [ "version" ];
user = "www-data";
group = "www-data";
virtualHosts."example.com" = {
documentRoot = "/var/www/html/magento2/pub";
};
};

It generates this piece of code in httpd.conf:

<Directory "/var/www/html/magento2/pub">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

I want to change the override settings to AllowOverride All in order to make the website work. I know I can add extraConfig field, but this would only append more config code, not alter the existing one.

hmm it’s been a long time now but i think you need this:

services.httpd.virtualHosts."example.com".extraConfig = ''
  <Directory "/var/www/html/magento2/pub">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
  </Directory>
'';

This is what I already tried. It just puts the extraConfig block below the automatically generated block, which looks like a duplicate. For now it seems to work. Is it guaranteed to continue to work?

In former attempts I dismissed the extraConfig approach, when I was still missing the extraModules version.

yes, that will continue to work - httpd has extremely well defined merging semantics, which you can read about in its documentation, that will explain why this works and will continue to :+1:

1 Like