# Give Apache write permissions on mounted share.



## mickey79 (Mar 22, 2007)

Ave,

I&#8217;ve run into a permissions snag.
I have Apache Web Server running on Mac OS X with PHP. I have a folder on a windows machine mounted on my Mac OS X as a share using the &#8220;mount &#8211;t  smbfs  //user@192.168.1.2/ShareName Share&#8221;. The &#8220;user&#8221; has full read-write permission and physically I&#8217;m able to do anything I want sitting on my Mac OS X in this share, like create, delete or modify files.

The problem is, I don&#8217;t think Apache Web Server (or PHP) has write access on this share. In PHP, I&#8217;m able to read data from files on this share, but I&#8217;m not able to write data to any file on that share. I get access is denied.

Is there anyway while mounting to give Apache write access to the files on this share? I don&#8217;t see how I can provide Apache Web Server (installed on my Mac) Write Access through the Windows System that has the original folder. Windows is only able to provide the Mac User with Permissions, not Apache.

Any help would be appreciated.

Thanks


----------



## jlpp (Mar 24, 2007)

Mickey, 

Did you have any difficulties getting Apache to read files off of the SMB mounted volume?  I'm having problems with just that much.  Despite the volume having R-X for world in all recursively I get the following error in the Apache logs: Permission defined: access to /alias failed because search permissions are missing on a component of the path.  By the way, I couldn't use OSX's SMB/CIFS mount GUI tool to get those permissions.  I had to use mount_smb at the terminal.  How did you get past this Apache/SMB read permissions glitch?  It was suggested to me that I should be using CIFS (ie mount -t cifs) instead of SMB but it looks like 10.4 doesn't support CIFS.  And that's another question I have: why not?  I see references on the web to Mac mount_cifs in earlier versions of OSX.  Was it removed?  If so, why and how can I install it?

Thanks,
jlpp


----------



## mickey79 (Mar 26, 2007)

Ave,

I was able to find the solution for it. Logically it's simple, at the time of mounting your Windows Share on your Mac OS X as an SMB share, simply specify Apache Web Server as the User & Group owner of the entire share. Thereafter Apache Web Server will have Full Rights to Anything residing on that share. 

Technically how to do this took me a while, but I finally found the commands.

The command (in my case) is:

mount_smbfs -u 70 -g 70 //user@ServerName/ShareName SharePoint

The "70" that you see is both the UID and GID of Apache Web Server in my Mac OS X. It may be different in yours but you can find that out in the NetInfo Manager. By giving the "-u 70 -g 70" parameters, we're basically instructing that the mounted share should be owned by Apache Web Server and not the root or any other user. 

If you did "ls -la" on the share in Terminal, you will see "www" in both Owner & Group columns.

This solved it for me. Any php script on my Apache Web Server was able to read/write any file on the Share!

Mickey


----------



## jlpp (Mar 26, 2007)

Hmm...  I tried your fix and it didn't work for me.  Apache still can't read the volume.  It gives the same error.  I think my problem might be something very unusual; either a bug or a bad configuration problem somewhere.  Anyway, if anyone can suggest how I might troubleshoot this problem, let me know.  Here's the error again for the record: Permission denied: access to /aliastosmbvolume failed because search permissions are missing on a component of the path.

Thanks,
jlpp


----------



## jlpp (Mar 26, 2007)

I found that the problem was somehow caused by the path in which the mount was defined not being owned by www:www.  I don't know why that had the effect it did as this directory was originally owned by a different user but set up to be r+x to world.  Anyway, a quick sudo chown www:www dirname fixed the problem.


----------

