I’ve set up an Ubuntu LAMP server for use with a Windows machine over a local network. This was primarily so my wife could develop websites from her desktop Windows machine on a local LAMP server before uploading to our live server.

I was writing some tracking code in PHP for one of those websites and needed to gain access to this local test server myself. It made sense to me that it would be simpler if I gave myself access from my Windows desktop to the same webpage files as my wife. Here’s how I did it.

First I needed to give myself a user account on that server.

sudo useradd neil
sudo passwd neil

Then I created a group called ‘usboth’ and added both my username and my wife’s to it.

sudo groupadd usboth
sudo usermod -a -G usboth neil
sudo usermod -a -G usboth amanda

I then needed to change the group ownership of the webpages directory to allow users in that group writable access.

sudo chgrp -R usboth /home/amanda/webpages
sudo chmod g+w /home/amanda/webpages

Altering Samba settings

Samba allows us to connect to our files from our Windows Desktops, so first I needed to add myself as a samba user.

sudo ambpasswd -a neil

And then edit smb.conf.

sudo pico -w /etc/samba/smb.conf

Altering Amanda’s configuration at the bottom of the file to this:-

[amanda]
path = /home/amanda/webpages
valid users = @usboth
available = yes
browsable = yes
public = no
writable = yes
force group = usboth
inherit acls = yes
create mask = 0666
directory mask = 0775

And then replicating it for me like so:-

[neil]
path = /home/amanda/webpages
valid users = @usboth
available = yes
browsable = yes
public = no
writable = yes
force group = usboth
inherit acls = yes
create mask = 0666
directory mask = 0775

Restart samba and we’re done.

sudo /etc/init.d/samba restart

If you find that now apache can’t read those files you may need to alter the permissions.

sudo chmod -R 777 /home/amanda/webpages

But with the samba settings above any new files created from now on should be fine.

We can now both map the webpages directory as a network drive and work collaboratively on the same files before uploading them live. Just the job!