How i can use the server root on apache

so i usually using apache and i usually just put my files on htdocs but it’s read-only so how i can move it(to home for example) so i can use it?

hopefully I understood correctly what your issue is but have you tried setting the services.httpd.virtualHosts.<name>.documentRoot option

1 Like

try something like this:

{ config, ... }:
{
  services.httpd.enable = true; 
  services.httpd.virtualHosts = {
    localhost = {
      documentRoot = "/srv/htdocs";
    };
  };

  systemd.tmpfiles.rules = [
    "d /srv/htdocs 0775 ${config.services.httpd.user} ${config.services.httpd.group}"
  ];

  users.users.nessa.extraGroups = [
    config.services.httpd.group
  ];
}

from there you can write into /srv/htdocs and access via apache

1 Like

how i access it? just type localhost/file?

yes, that should work

issues?

yes it is its say access forbidden

does the apache user have read access on the files you put there? maybe you can provide some details


here’s my config i don’t know where’s wrong from it

oh you’re using your home directory, not /srv

your home directory permissions are too strict so you can either loosen them up or run apache as the root user

see here for how to run as root

it’s fix now i just put this on my config and do this command, thanks for your help sir

chmod o+x /home /home/nessa
     extraConfig = ''
      <Directory "/home/nessa/.htdocs">
        Require all granted
        Options Indexes FollowSymLinks
        AllowOverride All
      </Directory>
      '';
    };
  };

change that to users.users.nessa.homeMode = "0755"; (or whatever) to ensure things keep working

also, i am not sure that extra config is actually required… :thinking: but i can’t recall for sure

glad we got you sorted :+1:

aight sir, thank you