OK, next step, adding the “AMP” (Apache, MySql, PHP) to the “L” (Linux) in the desktop version of Ubuntu 8.10. I’m actually writing this as I do this, so what I say now might turn out to need tweaking. But, I’ve got my 8.10 desktop installed, updated, and have made a few personalization one normally makes. Now I found this page at the Ubuntu site that looks as if it has all the info. So we’ll follow along and see if what that page say really works.
So, step one: from a terminal, enter:
sudo tasksel install lamp-server
Took about 3 minutes, had to enter MySql password in the process.
So, now I open Firefox, enter the local address (http://localhost/) and there it is! The install worked. Total time, less than 10 minutes. But we’re not done. Need to talk to the outside world now, and set up virtual hosts so we can get in multiple ways on multiple test web sites.
So since I had my previous version set up to host a domain (using dyndns.com, more on how to do that later), I tired entering that name – nope, doesn’t work. Need to fix something. Tried my machines current real IP address. Nope. Think I might have to fix the router tables. As part of the install of Ubuntu by Fusion, each VM gets its own MAC address, which is what the router uses to assign a local IP to connected machines. So I use “ifconfig” to get my current VM’s IP.
So now I’m in the router admin panel, and there is the ubuntu machine listed in the LAN computer table. Now I have to change some settings for the router’s virtual server tables. This will likely be a bit different on each router, but on my D-Link it is under the Advanced tab. I need three entries – HTTP, HTTPS, and SMTP. These need the correct Port numbers (HTTP: 80, HTTPS: 443, and SMTP:25) and the IP address of the Ubuntu VM box. AND THAT DID IT! I can now talk to the Apache server from any outside computer using a real URL.
[UPDATE: 4/19/2010] This works with an Apple Airport, too, but the getting to the settings is a bit different. Use the Airport Utility. Go to the “Advanced” tab, pick port mapping. Now use the “+” button to add the three above services – Personal Web Sharing, SMTP Mail, and Remote Login – SSH for https (I guess – couldn’t find another way to do that one). Then use the local IP of you Ubuntu box instead of the default provided by AirPort Utility, and your all set.
By the way, the actual location of the web site in the filesystem:
Total time, including writing this, 20 minutes. This seems MUCH faster than the last time I tried this, but I know more what I’m doing. Like all that business about the settings on the router – easy now, but I think it was hard the first time.
So, what’s next? We’ll set up a couple of extra Virtual Servers so it is possible to create and test multiple web sites. Then we need to make sure MySql is working properly. Finally, we will be sure PHP 5 has all the libraries and features installed and customize some of its settings to match those on my real host.
So, how did I get a real URL to talk to my Ubuntu virtual machine? You need to use a dynamic IP server that maps a URL to a physical IP address. I use dyndns.com. They have a totally free service which requires you to manually confirm things once a month. Or you can pay a little, and it doesn’t nag you.
Here’s how it works. You actually are using a real IP address to connect to the web from your house. This address is assigned by your ISP in some manner. The main thing is that the address is not normally permanent. It most probably will change from day to day. So if you want to talk to your server from the outside world, you have to be able to map a permanent URL to a real changing IP address. This is what dyndns.com does (and there are others, but I’ve had excellent look with dyndns.com).
It provides a bunch of main domain names like “dnsalias.com” and a bunch of others. You get to choose from those and create your own sub-domain on that – for example: mytestsite.dnsalias.com. You also need to keep dyndns.com updated with your real IP. Depending on your router, this isn’t that hard.
Most current routers already know about dyndns.com (and others, but dyndns.com seems to be the best supported by routers). You set them up to automatically report your current IP to dyndns.com. I won’t give all the details because they differ, but that’s the main idea – set up a dyndns.com domain (or several), set up your router to auto-update the IP, and you’re ready to have the world talk to your Ubuntu server.
If your router doesn’t have this, they have DynDNS update clients that run on Windows, Mac, and Linux. Dyndns.com says the software clients are better, but I’ve never had any difficulty with my router based version. (On the other hand, my comcast assigned IP doesn’t seem to ever change unless I have a power glitch or otherwise have to reset the router, and even then I sometimes get the same IP.)
So there we have it – while I’m addressing building a Mac Fusion Ubuntu Virtual Machine LAMP server, essentially everything I’ve covered would apply equally to a fresh install of Ubuntu on real hardware. But it is so nice to have everything right there on one physical machine. Part of why I really love my Mac.
Next time – tweaking Apache, adding Virtual Hosts.