Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Apache access to files on another server

Posted on 2013-01-31
11
Medium Priority
?
284 Views
Last Modified: 2013-02-04
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
Comment
Question by:AielloJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38841692
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
 
LVL 13

Author Comment

by:AielloJ
ID: 38841774
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
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38842021
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 13

Author Comment

by:AielloJ
ID: 38843250
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
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1000 total points
ID: 38844769
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
 
LVL 13

Author Comment

by:AielloJ
ID: 38845284
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
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38845458
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
 
LVL 13

Author Comment

by:AielloJ
ID: 38845474
Yes.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38845640
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
 
LVL 16

Accepted Solution

by:
grahamnonweiler earned 1000 total points
ID: 38846820
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
 
LVL 13

Author Closing Comment

by:AielloJ
ID: 38850583
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

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question