Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to understand what my problem might be here:

I am using a web application built on LAMP that needs access to a samba share that I've successfully mounted using

mount -t cifs ...

In the application, the samba share isn't accessible like other directories are. However, I can access it through the terminal just fine. Is this a permissions issue with Apache? If so, how would I grant permissions to apache from the remote computer?

share|improve this question

1 Answer 1

It does sound like a permissions issue - whichever user Apache is running as probably doesn't have access to the share.

There are a couple of ways around this, depending on what is hosting the samba share. The simplest method would be to force the owner and group when mounting to be the Apache user/group. This kinda maps a particular user/group on your system to the user credentials used to connect to the share (someone else feel free to come in with a better explanation here).

Assuming you haven't used suexec, Apache is probably running as the user "www-data". If Apache is running as any other user, you'll have to modify the commands below to replace www-data with the appropriate user and group names.

Example:

mount -t cifs -o user=smbusername,uid=www-data,gid=www-data //server/stuff /mnt/stuff/

When mounted, www-data will appear to be the owner of the mount point, and Apache will be able to read it.

Note that this gives Apache whatever rights you've assigned to smbusername on the samba server. Depending on what you want to do, you might want to mount it as read-only, by adding "ro" to the options:

mount -t cifs -o user=smbusername,uid=www-data,gid=www-data,ro //server/stuff /mnt/stuff/

This may differ slightly depending on your versions of Apache and samba/cifs - let me know if it isn't working, and what OS and versions you're using, and I'll try to help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.