I've Apache/2.2.11 using mod_python 3.3.1/Python 2.5 running under Gentoo linux. During my python script I invoke a win32 exe using wine (os.popen2 call). This works fine outdoors of Apache but under mod_python I recieve:

wine: cannot open /root/.wine : Permission refused

in /var/log/apache/error_log. My apache install isn't running because the root user/group. Any ideas why it's considering /root/.wine?



It's most likely because $HOME is not set properly...

Btw. Are you currently really sure invoking wine from mod_python may be beneficial?

If you're sure, something of that nature perform...

from subprocess import Popen        

HOME = '/the/home/of/www-data' #PLEASE edit
proc = Popen(cmd, shell=False, stdin=PIPE,
             stdout=PIPE, stderr=PIPE, close_fds=True,
             cwd=HOME, env={"HOME":HOME)

I had been also getting very difficult time and did plenty of investigated but unsuccessful. Finally found the easiest way with the addition of 'WINEPREFIX="/srv/www/.wine"' in /etc/init.d/httpd file as:

case $ARGV in
    WINEPREFIX="/srv/www/.wine" $HTTPD -k $ARGV

Copy /root/.wine to /srv/www/.wine and alter the dog owner to apache (from root). Hope this can solve the issue.