环境 linux + apache2.4 + php5.6
期望实现:可以通过php的file_get_contents()方法直接访问局域网内共享目录的文件
(windows下可以直接访问不需要配置,但linux下访问不了。目前可以 1.通过挂载磁盘的方法解决 2.通过调用smbclient实现。 但是不想用这个方法,就想知道能不能通过配置apache实现。网上说可以,配置如下,但是我试了不可以,不知道有什么问题,权限?)
我在 http-vhosts.conf配置了如下
servername 127.0.0.1 directoryindex index.php documentroot /www/htdocs/ alias /myshare //10.173.32.4/myshare allowoverride none order allow,deny allow from all
麻烦指点一下,谢谢!
回复内容: 环境 linux + apache2.4 + php5.6
期望实现:可以通过php的file_get_contents()方法直接访问局域网内共享目录的文件
(windows下可以直接访问不需要配置,但linux下访问不了。目前可以 1.通过挂载磁盘的方法解决 2.通过调用smbclient实现。 但是不想用这个方法,就想知道能不能通过配置apache实现。网上说可以,配置如下,但是我试了不可以,不知道有什么问题,权限?)
我在 http-vhosts.conf配置了如下
servername 127.0.0.1 directoryindex index.php documentroot /www/htdocs/ alias /myshare //10.173.32.4/myshare allowoverride none order allow,deny allow from all
麻烦指点一下,谢谢!
你这个是外部访问,不是 php 访问的
正解参见 so
http://stackoverflow.com/questions/5070545/php-read-file-contents-of-network-share-file
mount -t cifs //10.173.32.4/myshare /www/htdocs/myshare
然后
$data = file_get_contents('/www/htdocs/myshare/file.txt');