Question

I have Apache/2.2.11 using mod_python 3.3.1/Python 2.5 running under Gentoo linux. In my python script I invoke a win32 exe using wine (os.popen2 call). This works fine outside of Apache but under mod_python I get:

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

in /var/log/apache/error_log. My apache install is not running as the root user/group. Any ideas why it's looking into /root/.wine?

Was it helpful?

Solution

It's probably because $HOME isn't set correctly...

Btw. Are you really sure invoking wine from mod_python is a good idea?

If you are sure, something like that could work...

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)

OTHER TIPS

I was also having very hard time and did lots of researched but failed. Finally found the simplest way by adding 'WINEPREFIX="/srv/www/.wine"' in /etc/init.d/httpd file as:

case $ARGV in
start|stop|restart|graceful|graceful-stop)
    WINEPREFIX="/srv/www/.wine" $HTTPD -k $ARGV
    ERROR=$?
    ;;

Copy /root/.wine to /srv/www/.wine and change the owner to apache (from root). Hope this will solve the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top