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.

Follow up on my Ubuntu LAMP how to

It’s been over a year since I wrote ‘How to set up LAMP on Ubuntu Desktop Edition‘. Has anything changed? Is there anything to add? Let’s find out.

My wife is now working with me so I have decided that she too requires her own dev server, giving me a perfect opportunity to start from scratch. I downloaded the latest edition of Ubuntu (Ubuntu 8.0.4 LTS Desktop Edition to be exact) and followed my old howto.

What has changed?

Fortunately not a lot. However, there are a couple of things to note.

When installing mysql-server you have to define a root password. I can’t recall doing that before. No biggy, just enter a password and get on with it.

However, when installing phpmyadmin you have to specify that you want to use it with apache2. NOTE: you have to specifically choose apache2 by hitting space and then return. If you simply hit return (what I did) then no alias is setup to allow you to access phpmyadmin via http://localhost/phpmyadmin/. What if you made that mistake too? Here’s what I did:-

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
sudo /etc/init.d/apache2 restart

Apart from that little hiccup everything worked fine like before.

Is there anything to add?

My previous post attracted quite a few support comments, so it’s worth reading over those if you have any questions that may already be answered there. I am going to outline one niggle below though.

Each time you restart apache2 you get this message:-

apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

This is unimportant unless you are running a live server that should have a fully qualified domain name! Nevertheless, it’s a little annoying and can be fixed like this:-

gksudo gedit /etc/apache2/httpd.conf

Add the line:-

ServerName localhost

Restart apache2

sudo /etc/init.d/apache2 restart

And the message should no longer appear.

That’s it! If you have any questions with regard to setting up LAMP on the Ubuntu Desktop Edition then please don’t hesitate to leave them below and I’ll do my best to answer them.

For my next post I will be describing in detail how I set up my wife’s laptop (running Windows Vista) to use her Ubuntu test server as a mapped network drive, allowing her to work on files ‘live’.

This is my ideal setup, as it gives you the benefits of using windows for your desktop environment while at the same time giving you the power of working on your websites directly on a LAMP server. The only disadvantage is that it requires 2 computers, but with the cost being so low these days this shouldn’t be a huge problem. Time to dust off that old computer in the corner and use it as a LAMP server.

How to set up LAMP on Ubuntu Desktop Edition

So I’m now using my second laptop as a Linux dev server. Ubuntu is what all the cool kids are using so I thought I’d give it a go. Wait a minute, oh crap, I have to make a choice between Ubuntu Desktop Edition and Ubuntu Server Edition. Well I want to use it as a LAMP server but at the same time I want a desktop and all that comes with it. I figured I’d be able to download the Desktop Edition and sort it out later. I am happy to report I was correct, but I learned a little on the way. Here’s how you do it.

First off I downloaded and installed Ubuntu Desktop Edition. That went very smoothly, however I was a little concerned that although I created a user account during installation I wasn’t asked to specify a root password. All became clear after I discovered that they use sudo instead - in fact there is actually no root account by default.

This is also the first time I’ve used a Debian based distribution. Only now can I see why people have been banging on about apt-get and how slick it is.

sudo apt-get install apache2

As simple as that. Done. Apache 2 is now installed and ready to use. Amazing.

sudo apt-get install php5
sudo /etc/init.d/apache2 restart

Same for php5. Wow.

sudo apt-get install mysql-server
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
sudo apt-get install phpmyadmin

You get the picture…

I just had to edit php.ini to enable the extension.

gksudo gedit /etc/php5/apache2/php.ini
extension=mysql.so

Restart Apache again and I’m done.

My gob is still smacked.

I’m still adjusting to this whole no root account business, but at first glance Ubuntu gets the thumbs up from me.

See my follow-up post here.

Kevin Eldon: Speakers monologue series

Kevin Eldon is underrated in my opinion. This gives me as good a reason as any to make my first post here about him. Ever since his Simon Quinlank (hobby man) character I’ve been a big fan. I hope perhaps one day to add his autograph to my collection ;)

In 2005 he performed 8 audio monologues for Resonance fm. However they make them damn awkward to get at so I will link to them directly below.

Speakers #1: Lecturer
Speakers #2: Therapy
Speakers #3: Space
Speakers #4: Decree
Speakers #5: Induction
Speakers #6: Communication
Speakers #7: Transmission
Speakers #8: Francais

My favourites have got to be Français, Communication and Transmission.