Ubuntu – How to share apache /var/www using samba server in ubuntu

apache-2.2linux-networkingnetwork-sharesambaUbuntu

My issue is similar to the stackoverflow question, virtual centOS 6.2 – How to share /var/www using Samba, however I am getting the following error:

Windows cannot access \server1\dev You do not have permission to access \\server1\dev

I installed ubuntu server and I am trying to give the /var/www/html/dev directory read and write permissions from other computers (ex: windows 7 and ubuntu desktop).

I changed the owner of folder /var/www to the www-data group and added user dev1 to that group. I then gave 0755 permission to the folder /var/www And below are the contents of my smb.conf file:

[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
dns proxy = no

#============================ Share Definitions ============================== 
[sharing]
path = /samba/share
browsable =yes
writable = yes
guest ok = yes
read only = no
force user = nobody

[dev]
path = /var/www/html/dev
valid users = @www-data
read only = no
guest ok = no
writable = yes
browsable = yes

So I am tried to access the dev share using a password. I have also added a samba user by following this tutorial, but when I attempt to access this share from windows 7 machine, I receive the following error message:

Windows cannot access \server1\dev.  You do not have permission to access \\server1\dev  

Additional information

I can access /samba/share but cannot access the dev share.

EDIT: Now the windwos system asking to enter password. But after entering password I get the error \\s1\dev is not accessible. You might not have permission to use this network resource. Contact the administrator of this server to find out if you have access permissions.

Best Answer

Credit: Martin

You need to change your samba mount configuration so that you give permission to the www-data user and group to write to it. You may or may not have the ability to set specific directory permissions, but if not you'll have to set the entire drive the write access (which is bad for security).

I would personally advise using nfs instead of samba shares for networked storage and the use of ext3 or other fully featured file system.

http://www.cyberciti.biz/tips/how-do-i-set-permissions-to-samba-shares.html

https://help.ubuntu.com/community/Samba/SambaClientGuide

http://www.mattvanstone.com/2006/06/automatically_mounting_smb_sha/