Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

Apache access to files on another server

I'm running a php application that has to be able to access files on another server.  ie: Webserver is 192.168.1.4 and needs to access files on a folder in 192.168.1.14.

Tried to create an alias through Apache, but was not able to return a valid file handle using readdir() or scandir().

Thank you in advance.

AielloJ
0
AielloJ
Asked:
AielloJ
  • 5
  • 5
2 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
You probably are not able to get the correct permissions.  What OS?  You might be able to create a mapped drive on Windows that will give you local access.  If the remote files are on a web server, then PHP can access them.  If they are PHP files though, you can't get the code in them, only the results.
0
 
AielloJAuthor Commented:
Hi Dave,

I'm running Apache under Windows 7.  I created a mapped drive and a symbolic link using MKLINK.  Both were successful, but neither allowed access to the other drive.  The files I'm trying to access are text files I'm processing through the PHP script.  The C:\EDI folder in the example below is a a symbolic link to the 192.168.1.14 machine.

Alias /EDI/ "C:/EDI/"

<Directory "C:/EDI/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order allow,deny
    Allow from all
</Directory>

I'm also not certain what the directory name I should be using inmy PHP code.  I've seen
  //servername/sitename/alias
  /sitename/alias
and a variety of other formats as the directory/folder syntax.

My preference would be to just be able to create an Apache alias and not have to do anything special in the Win7 or Win7/DOC area.

Best regards,

AielloJ
0
 
Dave BaldwinFixer of ProblemsCommented:
An Apache alias won't get you around the permissions problems.  Apache itself is set up with very limited access and that is only to the directories specified in 'httpd.conf'.  But Windows (and Linux too) permissions also have to be set to allow access.  There is no way to do it only with Apache.  Windows 7 is pickier about permissions anyway.
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
AielloJAuthor Commented:
I'm a domain administrator, so access shouldn't be an issue, unless Apache runs at a different priority.  This is for a small intranet, and I'm the IT Administrator.  Can I add the directories into the 'httpd.conf' file?
0
 
Dave BaldwinFixer of ProblemsCommented:
Yes, 'httpd.conf' is the place to add them.  But every file and directory has specific permissions.  Adding them to Apache does not change or override that.  Files on another machine have to 'shared' to access them remotely at all.  Windows normally blocks external access to 'My Documents' from other users because it belongs to a specific user.
0
 
AielloJAuthor Commented:
Dave,

Since all the machines are on the domain, is there a domain username or group that Apache runs under?  I could give the appropriate permissions to the group or account.

AielloJ
0
 
Dave BaldwinFixer of ProblemsCommented:
I have never had a Windows domain setup so I don't know.  Can you directly access the directory you're talking about without a login from the computer where Apache is running?
0
 
AielloJAuthor Commented:
Yes.
0
 
Dave BaldwinFixer of ProblemsCommented:
I can't get it to work on my Windows XP network.  I have 'alias' working fine for local directories.  But I can't get it to work with a direct remote access or a mapped drive setup.  I don't know what else to tell you.  You can click on "Request Attention" above and see if someone else can help you.
0
 
grahamnonweilerCommented:
On Windows (regardless of version), both Apache and therefore PHP, run at the "system" level. When you login to windows and create a mapped drive then you are creating that at whatever "user" you have logged in as - which neither Apache nor PHP have access to.

PHP can however access a different drive within the same network provided that drive is open to "everyone" - meaning no security/permissions at all. In PHP you would acess the drive using SMB, for instance:

\\192.168.1.14\edi\myfile.txt

However, as the backslash would be treated as an escape sequence by PHP you need to "double" up, for example:

\\\\192.168.1.14\\edi\\myfile.txt

Obviously, as there is no ability to "secure" the shared drive, this is not anideal situation, and therefore you should ensure you at least secure access to the shared resource by IP addresses.

While an "alias" within the HTTP.CONF (using the same method as stated above) on Apache will "sometimes" work in Windows, it is by no means reliable, and thus the direct access through PHP is the more reliable option.

Again I would stress, that this does introduce new security aspects that need to be considered carefully before attempting to use this in a production environment.
0
 
AielloJAuthor Commented:
Thanks for the help guys.  Found the solution and thought I'd share it.  Apache runs at the access level of the system it's installed on, regardless of what system we want to access files on.  Go into Control Panel -> Services and right click on the Apache service (wampapache on WAMP).  There's a tab that says Login As.  Set the login account as one that has access to the system you're trying to access the files on.

Points in appreciation for your efforts.

Best regards,

AielloJ
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now