Allow Apache/PHP a read/write access to a mounted directory

不羁岁月 提交于 2019-11-30 23:29:29

our team had the same issue, my team-mate was able to resolve this by adding context to mount options.

we are using the following format for mounting windows shared folder to linux that apache will be able to access:

mount -v -t cifs <//$hostname/$(windows shared dir)> <mount directory> -o username="<username>",password=<password>,domain=<domain name>,iocharset=utf8,file_mode=0777,dir_mode=0777,context="system_u:object_r:httpd_sys_content_t:s0"

For example:

mount -v -t cifs //192.168.1.19/sample_dir /mnt/mount_dir -o username="admin",password=adminpwd,domain=MIINTER,iocharset=utf8,file_mode=0777,dir_mode=0777,context="system_u:object_r:httpd_sys_content_t:s0"

Link the mounted directory to your www root dir and name the link "share"

ln -s /mnt/some_directory /path/to/your/www/root/directory/share

than try reading the file

php -r "print_r(file_get_contents('/path/to/your/www/root/directory/share/file_name.txt'));"

...or you can allow (if you have enough privileges to edit the webserver's configuration)

<Directory /mnt/somedirectory >
    Allow from All
<Directory>
L.Tomas

i have seen the same problem with a cifs mount linux/unix apache that user can have access to the mounted volume, but not apache.

see also this: EnableSendfile off

but when turned off, apache may work slowly, in .htaccess, only for the cifs mount path, it should work ... .

http://httpd.apache.org/docs/current/en/mod/core.html

best regards L.Tomas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!