我正在尝试在RHEL6上运行mod_wsgi应用程序,无论我如何尝试,我似乎都无法建立FIFO。我认为这可能是一个权限问题,但我无法弄明白。
这是httpd配置的相关部分:
WSGIDaemonProcess loris user=loris group=loris processes=10 threads=15 maximum-requests=10000
WSGISocketPrefix /var/run/wsgi
WSGIProcessGroup loris
<Directory /var/www/loris>
Order allow,deny
Allow from all
</Directory>
这是一个最低工作示例(Python 2.7):
import getpass
import os
import subprocess
def application(environ, start_response):
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
path = '/var/www/loris'
c = ''
c += 'user: %s\n' % getpass.getuser() # prints 'loris', as expected
# try opening a file; works fine
f = open('%s/open.txt' % path, 'w')
f.write('ok\n')
f.close()
c += 'we can write a file\n'
# try 'touching' a file; works fine
call = '/bin/touch %s/touch.txt' % path
s = subprocess.check_call(call, shell=True)
c += '/bin/touch status = %s' % s # prints 0, as expected
# try shelling out to mkfifo; doesn't work
# Error msg: '/usr/bin/mkfifo: cannot create fifo `/var/www/loris/binfifo':
# Permission denied'
call = '/usr/bin/mkfifo %s/binfifo' % path
s = subprocess.check_call(call, shell=True)
# throws a 500 error
# try os.mkfifo(); doesn't work either
fifo_path = '%s/os_fifo' % path
os.mkfifo(fifo_path)
s = subprocess.check_call(call, shell=True)
# again, 'OSError: [Errno 13] Permission denied'
start_response(status, response_headers)
return c
显然,用户有权写入目录,但看起来mkfifo
特别是问题(因为/bin/touch
工作正常)。我可以自己做一个fifo,所以文件系统支持它们。我也可以用py os.mkfifo()
在python shell中以两种方式(shelling out和loris
)制作fifos。我认为这与mod_wsgi和权限有关,但我想不出还有什么可以尝试。