Home > Backend Development > PHP Tutorial > Problem with Apache configuration to access LAN shared directory

Problem with Apache configuration to access LAN shared directory

WBOY
Release: 2016-07-06 13:52:13
Original
1539 people have browsed it

Environment Linux Apache2.4 php5.6

Expected realization: You can directly access files in the shared directory in the LAN through the file_get_contents() method of PHP
(It can be accessed directly under Windows without configuration, but cannot be accessed under Linux. Currently, you can 1. By mounting the disk Solution 2. Implement it by calling smbclient. But I don’t want to use this method, so I want to know if it can be achieved by configuring Apache. The Internet says it can be done, and the configuration is as follows, but I tried it and it doesn’t work. I don’t know what the problem is, permissions?)

I configured the following in http-vhosts.conf

<code> 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></code>
Copy after login
Copy after login

Please give me some advice, thank you!

Reply content:

Environment Linux Apache2.4 php5.6

Expected realization: You can directly access files in the shared directory in the LAN through the file_get_contents() method of PHP
(It can be accessed directly under Windows without configuration, but cannot be accessed under Linux. Currently, you can 1. By mounting the disk Solution 2. Implement it by calling smbclient. But I don’t want to use this method, so I want to know if it can be achieved by configuring Apache. The Internet says it can be done, and the configuration is as follows, but I tried it and it doesn’t work. I don’t know what the problem is, permissions?)

I configured the following in http-vhosts.conf

<code> 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></code>
Copy after login
Copy after login

Please give me some advice, thank you!

This is external access, not PHP access

For the correct answer, see SO
http://stackoverflow.com/questions/5070545/php-read-file-contents-of-network-share-file

<code>mount -t cifs //10.173.32.4/myshare /www/htdocs/myshare
</code>
Copy after login

Then

<code>$data = file_get_contents('/www/htdocs/myshare/file.txt');</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template