首页 > Apache配置访问局域网共享目录问题

Apache配置访问局域网共享目录问题

环境 Linux + Apache2.4 + php5.6

期望实现:可以通过php的file_get_contents()方法直接访问局域网内共享目录的文件
(windows下可以直接访问不需要配置,但linux下访问不了。目前可以 1.通过挂载磁盘的方法解决 2.通过调用smbclient实现。 但是不想用这个方法,就想知道能不能通过配置Apache实现。网上说可以,配置如下,但是我试了不可以,不知道有什么问题,权限?)

我在 http-vhosts.conf配置了如下
<VirtualHost *:80>

 Servername 127.0.0.1
 DirectoryIndex index.php
 Documentroot /www/htdocs/
 Alias /myshare "//10.173.32.4/myshare"
 <Directory "//10.173.32.4/myshare">
      AllowOverride None
      Order allow,deny
      Allow from all
 </Directory>

</VirtualHost>

麻烦指点一下,谢谢!


你这个是外部访问,不是 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');
【热门文章】
【热门文章】