Search code examples
linuxapache2privilegesmod-perl2

How do I change the working directory of Apache2/mod_perl2


I have a mod_perl2 module that writes some files to the working directory. The standard working directory of mod_perl2 or Apache2 seems to be "/". Of course, Apache is not allowed to write files in this directory.

Can anyone tell me how I can change the working directory or the directory mod_perl2 writes to?

I use Apache2 Prefork on SLES 10.


Solution

  • Can you do a perl chdir(script-dir) at the beginning of the script ?

    On a second thought that would defeat the purpose when you try to use in threaded scenario where changing the working directory might break the threads.

    You could try RegistryPrefork module ?

    # httpd.conf
    PerlModule ModPerl::RegistryPrefork
    Alias /perl-run/ /home/httpd/perl/
    <Location /perl-run>
      SetHandler perl-script
      PerlResponseHandler ModPerl::RegistryPrefork
      PerlOptions +ParseHeaders
      Options +ExecCGI
    </Location>