Turn Your Old Mac into a Web Server with Linux, Apache, MySQL, and PHP
- 2008.07.09 - Tip Jar
Popularity: ![]()
![]()
![]()
Low End Mac Reader Specials
Memory To Go Special: MacPro 8 Core Memory 4GB kit $154 / 2GB kit $94, New 2008 iMac 2GB $46. MacBook Pro / MacMini / iMac Intel Core2 DUO 2GB $44 / 1GB $23--Free shipping available.
Download Typestyler, still the Ultimate Styling Tool for Internet, Print and Video Graphics. Works great in Classic with a Native OS X Version on the way. Free Tryout: www.typestyler.com
LA Computer Company: Specials on AppleCare, iMac's, Apple Batteries and Apple A/C Adapters. Also Great prices on Used Apple Computers. Call 1-800-941-7654 Click Here.
OWC: Juice up your iPod w/NewerTech High Capacity Battery from $19.99 Free Installation Videos for most models. Pro Installation Service w/FedEx Shipping From $57.95 (Battery Included). - www.MacSales.com
Mac users can finally play Party Poker for Mac. Not only that, they can also learn how to play PokerStars for Mac.
Laptop Hardware Provided by TechRestore - Overnight Mac & iPod Repairs.
Compare products like desktop computers, laptops, and LCD TVs side by side! All the information and reviews to make the best purchasing decision for a new cell phone GPS products or MP3 players. The Ciao network makes searching products easy for you.
New iMac 800Mhz Memory 4GB $98, 2GB $50. Click to Maximize your Macs...
Last time I talked about pressing your aging Mac into service as a web server. To show that it can be done, and quite easily, I decided to take the plunge.
I have three Macs that qualify as "left behind": an eMac, an iBook, and a Power Mac 6500/225. I decided to take the middle ground and selected the iBook.
Why would you want to make a notebook into a server? Well, it's small and takes up little space in the server room. It has a built-in screen and keyboard for when you can't access it remotely. And it has a built-in battery backup in case of power failure! What's not to love?
Besides, I didn't want to cop out and use a machine that actually runs Leopard relatively well, nor did I want to make my demonstration more difficult than necessary (the 6500 has plenty of disk space, but only 72 MB of RAM - a little tight for a server, where 128 MB is a realistic minimum and at least 256 MB is recommended).
The Installer
I've admitted to my preference for Debian PPC when working with Macs, and that is what I chose for this demonstration as well. I downloaded the 'netinst' version of the installation CD rather than the whole DVD. I think it makes better use of online resources to do so - not only is the install image relatively small, weighing in at under 250 MB (there have been updates to OS X that were larger!), it also forces you to download the latest and greatest packages from the Internet during the installation, virtually guaranteeing you an up-to-date system at first boot, rather than after you've run Software Update umpteen times.
Pop this installer CD into your system and boot (while holding down the C key), and you'll see your Mac do something you've probably never seen before, nor wanted - boot into a text interface. From this initial boot loader, simply press Enter to accept the defaults. Unless your system is very old indeed or full of very odd hardware, it should serve you just fine.
Watch all the text notices about hardware detection and driver status scroll by and wait for the system to drop you at a blue and gray installation screen.
Put your mouse aside, as you won't be using it for the rest of the installation - nor for the life of the server, if you keep running Linux this way.
The installer uses your keyboard arrow keys and Tab key to navigate, and usually the Enter key to accept whatever settings you have chosen.
The first things you'll be asked about are your location, language, and keyboard layout. After you have answered and some additional components have been installed, you will be asked which network adapter you wish to use. Impressively, Debian 4.0 detected my AirPort card and loaded the necessary drivers for me to proceed with my installation wirelessly.
Next you will have to decide on a name for your server. Make it unique on your network - I choose "iBook", not terribly original - and also put in your domain name. If you don't have a domain or don't know how you'll be using the server, just fill in example.org. Both the server name and domain can be changed after the fact if you change your mind.
Partitioning Your Hard Drive
The most daunting part of installing Linux for most folks is partitioning the hard drive. Let me stop here and say that if you have data on this disk and have not made a backup of it, stop now and do so. What you do next could - either deliberately or accidentally - erase that data.
The easiest option is to let the software do the partitioning for you by choosing "Guided - use entire disk." This does exactly what it says, taking over the entire hard drive and creating a new Linux partition on it, erasing everything that's on it. Note that if you have more than one drive, you can choose this option and in the next step tell it which drive to do use.
Your other option is to choose "Manual" and partition the drive yourself. As I had no data on the drive of this iBook, I chose to let the system do it itself.
You should also probably let the system create one big partition for all of your Linux data. It's the easiest system to deal with, and honestly there are few drawbacks to doing it this way, especially for a single-use server like we're setting up.
After your partitions have been approved and set up, you will be asked about your time zone and then to enter a password for the root account. Root is the superuser, and you'll need that access when you're setting up software, but make the password something strong. You'll also be prompted to create a non-privileged user, one that you can use every day without fear of causing accidental damage to the system.
The system will then install the base packages that are located on the CD-ROM and are required for every system. You could stop there once it's done and install nothing else, but your system would be about as useful as a DOS box onto which you've loaded DOS . . . and nothing else.
Before you can install any additional software, you have to tell it where to look on the Internet. By choosing a mirror that is close to you geographically, you are hopefully picking one that will be fast as well. If, after the install, you decide you wish to use a different mirror, you can edit the mirror location in a configuration file, so this decision is not set in stone.
Once that decision is made, you'll be presented with a list of prepackaged installation options. The only one you need is the standard system. If you don't deselect Desktop Environment, you will wind up installing a graphical desktop and desktop applications like OpenOffice and Firefox that you probably don't want or need on a server. And while you could theoretically select Web Server and SQL Server from this list, you don't know what'll be installed in those packages. In the interest of keeping your system lean, I would recommend not selecting them and instead waiting to install them manually after the system is fully installed.
As soon as you say go, the installation will begin in earnest. It won't take long (how long is more dependent upon your Internet connection than the speed of your hardware) before the CD is ejected and you're told that it's time to reboot.
Setting Up Your Linux Server
Let the boot process run automatically, though you will see an option to boot from the CD if you need to, and an option to enter additional boot parameters - you won't likely need to use them. You'll know it's done when you're prompted to log in for the first time.
Log in as root - we need that superuser access to install the rest of the software and tweak the configuration just so. To install the software, you only need one command:
apt-get install apache2 php5 mysql-server phpmyadmin
Note that this will install the web server, PHP, the MySQL server, and a web-based MySQL administration tool. Also note that when you hit Enter, it tells you that in addition to these packages, it will be installing a bunch of necessary supporting packages - called dependencies - to ensure that everything works. Go ahead and say Yes to this process and wait while everything installs. It won't take long.
Once that is completed, there are two final tweaks to ensure that everything is working as expected. First, you must assign a password to the root account in the MySQL server. By default the password is blank, and that's a major security hole. Type the following command:
mysqladmin -u root password PASSWORD
only replace PASSWORD with an actual password. It can be the same as the root password to log into the system, though for security's sake, I wouldn't recommend it.
Finally, to enable the interaction of MySQL, PHP and Apache, you need to change one line in one configuration file. Type this command:
nano /etc/php5/apache2/php.ini
to open up a text editor and the appropriate config file. Press Ctrl-W to begin a search within the document and type in 'mysql' and hit enter. This will take you to a line that looks like this:
;extension=mysql.so
The semicolon indicates that this line has been 'commented out' and does not get loaded at boot time. Use your arrow keys to move up to it, and delete that semicolon. Then type Ctrl-O to save (hit enter to keep the same file name) and then Ctrl-X to exit the editor.
The last step is to restart the web server with one simple command:
/etc/init.d/apache2 restart
And you're in business. Go to a different machine on the same network, open up a browser and type in the IP address of your new server. Don't know what IP address it was assigned? From the command prompt on the server, type:
ifconfig
This will bring up information about each of your network interfaces, including the current IP address.
When you click Go or hit Enter, you will see a screen that says, in big letters "It Works!" - this tells you you've done it, your web server is serving up pages. To test that PHP and MySQL are working, replace the "apache2-default" part of the URL that you were redirected to with "phpmyadmin" to see a login screen for the administration tool. Enter root as the user and the password you assigned above using the mysqladmin command, and you'll be able to manipulate your MySQL database using a PHP program.
And that is that! Easy as pie, honestly, and nothing quite like the rat's nest of commands you had to use to configure Linux once upon a time. Now you're ready to start loading up content on the system and serving up web pages, dynamic as well as static, on hardware that used to be ready to be retired.
Looking to do more? Investigate installing an SSH server so you can
remotely connect to your server and manage it from another Mac. Look at
the webmin software package for
remote server maintenance via the Web. Or, if your hardware isn't quite
so obsolete, install a desktop environment and see just how much
peppier things are under Linux. The sky's the limit!
Recent Macs in the Enterprise Columns
- Debunking Mac Myths Is Not the Way to Get Apple in the Enterprise, 08.06. There are other factors at work that keep those with vested interests on the Windows platform. Mythbusting won't change their minds.
- How to upgrade your eMac without cracking the case, 07.14. Some people like to replace the components inside their computers, but with FireWire and USB 2.0, Apple has made it easy to upgrade using external drives.
- Turn your old Mac into a website server with free open source software, 07.02. By installing Linux without a GUI, your old Mac can dedicate all of its resources to running Apache, MySQL, and PHP.
- What Snow Leopard means for Macs in the enterprise, 06.25. With Exchange and Active Directory support coming in Mac OS X 10.6, two of the big obstacles to Macs in the workplace will be swept away.
- More in the Macs in the Enterprise index.
Links for the Day
- Mac of the Day: PowerBook 190cs, Aug. 1995 - The last 680x0-based PowerBook could take a PowerPC upgrade.
- List of the Day: Apple TV List The Apple TV List is a forum to discuss the Apple TV.
- August 28 in LEM history: 95: PowerBook Duo 2300 - 00: Gaming on older Power Macs - 01: AppleShare on Linux - From Beebs and Acorns to Macs - 02: Sleep of Death, - Think smarter? - It's the software, stupid - 06: PowerBook 5300 reminiscence - You might be a Mac fanatic if... - Hiding complexity behind elegant simplicity
Recent Content on Low End Mac
- 10 Mac Browsers Compared, Simon Royal, Mac Spectrum, 08.28. A look at Internet Explorer, Radon, Opera, Safari, Shiira, iCab, Firefox, Netscape Navigator, Flock, and Camino running in Leopard.
- Clone and Boot: Another Advantage of the Mac OS, Kev Kitchens, Kitchens Sync, 08.28. Unlike Windows, Apple makes it possible to clone a bootable drive (Classic Mac OS or OS X) and use it with another supported Mac.
- Best MacBook Deals, Low End Mac Deals, 08.28. Used 1.83 GHz, $799; 2.0 black, $875; refurb 2.1 GHz, $899; 2.4, $1,099; black, $1,299; new 2.1, $1,019 after rebate; 22, $1,094; 2.4, $1,219 a/r; black, $1,394 a/r.
- Best iMac G5 Deals, Low End Mac Deals, 08.28. Used 17" 1.6 GHz Combo, $499; 1.8 SuperDrive, $530; 2.0, $600; 1.9 iSight, $625; 20" 1.8 GHz, $580; 2.0, $650; 2.1 iSight, $700.
- Best classic Mac OS Deals, Low End Mac Deals, 08.28. System 6, $10; 7.1, $12; 7.5.1, $4; Mac OS 7.6, $13; 8.0, $13; 8.1, $48; 8.5, $25; 8.6, $20; 9.0, $20; 9.2.2, $20; more.
- CrossOver Strikes Out, Frank Fox, Stop the Noiz, 08.27. Running Windows apps on a Mac without paying for Windows is great in theory, but actually getting Windows software working is another story.
- MacDrought: 4 Months with No New Macs, Dan Knight, Mac Musings, 08.27. The most recent Mac update was over four months ago, and the Mac mini has been unchanged for over a year.
- Resurrecting a Dead Pismo, Spotlight Search Tip, and EasyFind a Good File Finder, Charles W. Moore, Miscellaneous Ramblings, 08.27. Lots of tips on bringing a comatose Pismo back to life, a Spotlight file name search tip, and EasyFind as an alternative to Spotlight.
- Best Intel iMac Deals, Low End Mac Deals, 08.27. Used 17" 1.83 GHz, $625; 20", $599; 2.16, $749; 24", $950; refurb 20" 2.4, $999; 2.66, $1,299; 24" 2.4, $1,299; 2.8, $1,549; new 3.06, $2,094 after rebate; more.
- Best 15" PowerBook G4 Deals, Low End Mac Deals, 08.27. Used 1.25 GHz Combo, $600; SuperDrive, $650; 1.33 Combo, $640; 1.5, $680; SD, $725; 1.67, $730; hi-res, $800.
- Best Time Capsule and AirPort Deals, Low End Mac Deals, 08.27. 500 GB Time Capsule, $294; 1 TB, $468; AirPort Extreme Card, $39; 802.11n Base Station, $166; 802.11g AirPort Express, $60; 802.11n, $98.
- Does Running OS X System Maintenance Routines Really Do Any Good?, Charles W. Moore, Miscellaneous Ramblings, 08.26. Mac OS X is designed to run certain maintenance routines daily, weekly, and monthly - but can't if your Mac is off or asleep.
- Purposeful Reincarnation for Old Macs, Phil Herlihy, The Usefulness Equation, 08.26. The key is to avoid spending more on upgrades than the final use of the machine can justify.
- Best Power Mac G5 Deals, Low End Mac Deals, 08.26. Used 1.6 GHz single SuperDrive, C$499; 1.8, $569; dual, $675, 2.0, $800; 2.3, C$899; 2.5, C$1,199; 2.7, $1,225; 2.5 Quad, $1,500.
- Best 17" MacBook Pro Deals, Low End Mac Deals, 08.26. Used 2.16 GHz Core Duo, $1,330; 2.33 C2D, $1,689; refurb, 2.4, $1,899; new, $2,099; 2.5, $2,558 after rebate; 2.6 Santa Rosa, $2,399 a/r; more.
- Best iPod shuffle Deals, Low End Mac Deals, 08.26. Refurb 3G 1 GB, $39; new 3G, $45; refurb 2 GB, $59; new, $68.
- More links in our archive.
About LEM | Support | Usage | Privacy | Contacts
