Home > General, My Issuses, PHP, tricks > Accessing network shared folder using PHP with XAMPP

Accessing network shared folder using PHP with XAMPP

Hi All,
I am encountering an issue while accessing Network drive using PHP with XAMPP from last 15 days.
Basically I never used XAMPP(with Window) in network throughout my programming career, & hence the issue is pretty new & confusion for me.
My Scenario:
I have a PC & a Laptop in LAN.Both having Windows 7 OS.I have installed an application on PC as well as Laptop.All data inserted into application from PC and I want to sync with Laptop on daily/weekly basis.
I searched a lot on internet and came across different techniques,I implement them but problem is not yet solved. Just Hereby briefing you all-
When you run Apache as a service on your Windows computer, it chooses to run as the LocalSystem account by default (usually SYSTEM). The LocalSystem account has no network privileges, makes it impossible to access networked resources (such as a shared drive) in your Apache service.

1. First, you have to change the user the Apache service runs as.
Go to your Services panel (Start -> Run -> “services.msc”).(Or tou can right-click My Computer icon on desktop,and select Manage)
Find the Service labeled Apache, right-click, and hit Properties.
Choose the “Log On” tab.
You’ll see that Apache is set up to run as the Local System Account.
You’ll want to change this to the second option, “This account”, and then fill in the details of the User account you would like Apache to run under.
Some sites tell you to create a special Apache-based user account just for this occasion. It’s not a bad idea, but then you have to make sure it has all of the proper permissions that an Apache user would need, such as read/write to to htdocs and the .conf and .log files, and permissions to log on as a service, etc etc – as well as the permissions to access the network resource you’re trying to get to in the first place.(I hadn’t tried this)
In light of that process, I chose to just run it under my own account instead.

To configure how a service is started using the Windows interface:
To specify account, click This account, click Browse, and then specify a user account in the Select User dialog box. When you are finished, click OK.If you still have problem to find exact User,go to advance option & then use “Find Now” functionality provided.Configure How a Service Is Started

Hit “Apply” – it’ll pop up a box saying you need to restart Apache to take effect, but hold off on that for a moment.
This is the tricky part: you have to give the user (the one you’re running Apache as) permissions to act as part of the OS.
Go to the Local Security Policy panel (Start -> Run -> “secpol.msc”).
Under the navigation section in the left sidebar, choose Local Policies -> User Rights Assignments.
In the right-hand frame, double-click the item “Act as part of the operating system” to open up its properties.
Select “Add User or Group, Enter the appropriate user in the box provided, and hit “OK.”
At this point, you are technically complete – Apache can now do the same things to the network resource that your user can – read, write, execute, whatever.
However, in Auther’s case, he was trying to create an actual readable resource, so he edited my Apache config file to create an alias to my share.
Open up your Apache configuration file. For most people it’s httpd.conf in the conf subdirectory of your Apache install directory.
The other thing that is tricky and caught me up is that unlike Apache, the Windows UNCs config file requires backslashes slashes, not forward. Now you can restart your Apache service
ref: http://php.net/manual/en/function.opendir.php

On Oct 22,2012:
Hurry…Now I can access the network folder,I even successfully transferred the files to the shared folder.
Now my next challenges:
1. File transfer time is bit more.
2. Transfer the Db files
Will get back if I can find some success..:)

Advertisements
  1. August 2, 2013 at 8:08 am

    you saved my ass. Apache actually starts and i can access the network drive. Sadly, my tablets still refuse to access my IP 😦

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: