Using your Ubuntu Apache test server with Windows
So we’ve set up our Ubuntu LAMP server, but now we want to use it to develop our wonderful websites. Years ago I only had one computer so I ran Linux on it and worked directly on the server itself as well as using it as my desktop. However, I personally prefer to use Windows as my desktop and use an entirely separate machine as my test LAMP server. I will be writing this ‘how to’ from that point of view, although there will be some things you can take away from this if you intend on running just Linux on one machine and nothing else.
NOTE: wherever you see username you need to change it for your actual Linux username.
Setting up a static IP address
Using the top menu navigate as follows:-
System > Administration > Network | Network Settings > Connections Tab > Choose Unlock > (enter password) > Choose Wired connection (or whatever connection method you use) > Properties > untick Enable roaming mode > choose:-
Configuration: Static IP Address
IPaddress: 192.168.1.xx , where xx is a number you choose between 0-255 (perhaps your network is 192.168.0.xx - so choose accordingly)
Subnet mask: 255.255.255.0
Gateway address: 192.168.1.1 (this is my router address, perhaps yours is 192.168.0.1 or something else!)
sudo /etc/init.d/networking restart
This basically ensures we have a static IP for our server. It means that when we want to see our website from our local network (on our Windows machine) we simply type in http://192.168.1.xx/ (whatever you chose as the IP address). Do it now and you should see the message “It works!”. If not, something went wrong.
Setting up samba
sudo apt-get install samba
sudo ambpasswd -a username
Where username is your Linux username. Here you want to have your Windows username and password identical to that of your Linux username and password. Capitals matter. If you log into Windows with Fred but your Linux username is fred then you need to change your Windows username to fred also. First change it to fred1 and then fred, because Windows thinks Fred and fred are the same and won’t change it directly.
gksudo /etc/samba/smb.conf
Find and set:-
workgroup = MSHOME
remove the semicolon (;) from the beginning of
security = user
And then at the very bottom of the conf file add:-
[username]
path = /home/username/webpages
available = yes
browsable = yes
public = no
writable = yes
Now save and exit and restart Samba
sudo /etc/init.d/samba restart
So now we can use our Windows machine to navigate the network, find our Ubuntu server and browse all our /home/username/ files. Personally I right click on here and choose to map as network drive so it’s easily available whenever I want it. We’re nearly there!
Configuring a new DocumentRoot for apache
Create a directory in your /home/username/ called webpages. This will be where we put the websites we work on. Now we need to make apache look there instead of /var/www/.
mkdir /home/username/webpages/testsite01
gksudo /etc/apache2/sites-available/default
Alter DocumentRoot /var/www/ to DocumentRoot /home/username/webpages/testsite01/
Also change Directory /var/www/ to Directory /home/username/webpages/ and then directly under this alter AllowOverride None to AllowOverride All.
Now restart apache and you’re done.
sudo /etc/init.d/apache restart
Whenever you want to work on a new website (say testsite02) then create the new folder under webpages and put all the working files in there. Then edit /etc/apache2/sites-available/default and put a # in front of the old DocumentRoot and put a new one underneath pointing to your new testsite02. Putting # in front acts as commenting it out. This makes it easy to switch between the sites you are working on, commenting and uncommenting DocumentRoot as appropriate. Don’t forget whenever you change DocumentRoot a restart of apache is required.
There are bound to be easier, better, more elegant ways to do this, but this is an example of how I do it and it works well for me, and maybe it could work well for you too.
