Home » Technology » Internet/Web (Page 15)

Category Archives: Internet/Web

The Most Versatile VoIP Provider: FREE PORTING

ISP-In-A-Box: The $500 Mac mini (Part IV, PHP)

We've been exploring the possibilities of the Mac mini for the past couple weeks with a series of articles covering first what it would take to turn the Mac mini into a Home Automation Server. And then we built a Computer Telephony Server. This week we're using the Mac mini to build a full-featured Internet Hosting Server a.k.a an ISP-In-A-Box. This is the fourth installment in our five-part ISP-In-A-Box series. If you're just joining us, you might want to start at the beginning and read the articles from the bottom up using this link. On the first day, we covered hardware requirements and installation and operation of the Apache Web Server. Day Two added mail services including SMTP, POP3, and IMAP servers. And yesterday we installed MySQL to handle all our data base chores.

Today we'll cover installation of PHP, a pedal-to-the-metal scripting and programming language that you can use to build or run web applications for just about anything. As we mentioned yesterday, adding PHP to the server with MySQL gives you access to literally thousands of free, commercial-quality applications that already have been written by talented programmers all over the world. Here's a partial list from just one of dozens of web sites that catalog these things. After we get PHP up and running, we'll install phpMyAdmin, your first PHP application. We'll use it to manage and create MySQL databases, and you can kiss the MySQL command prompt goodbye ... forever.

For those of you who are programmers or wannabe's, one of the beauties of PHP is its extensibility. In addition to the functions provided in the basic language, others have added function libraries for PHP covering almost every programming discipline you can imagine including imaging, printing, emailing, data base integration with virtually every DBMS on the planet, XML, SOAP, PDF, compression technologies, date, time, calendaring, TCP, URL and socket functions ... and we've barely scratched the surface. The documentation alone (in over two dozen languages) runs well over 1,000 pages. Assuming you decide to develop your own applications, if you've learned any other programming or scripting language including ASP or Visual Basic on the Microsoft platform or C on any platform, then you'll be right at home with PHP. If you're just getting started with programming, find a PHP course at your local community college or university. They all love PHP! But, as we noted earlier, one of the real beauties of PHP is not having to write any applications unless you want to. If there's some web-based application you needed yesterday for a project, chances are someone already has written it for you using PHP.

To simplify the installation process, we're going to use a PHP installation image (.dmg) file rather than a tarball just as we did with MySQL. We're going to install PHP 4.3.10 for OS X v10.3. Make sure you have applied the latest Apple patches to Panther before we begin. As already mentioned, PHP 5 is also available, but it is not yet in widespread use by ISP's, and many of the best PHP applications still require version 4. Click on this link for documentation about this PHP build and for other installation images. When you're ready to begin the actual download we'll be using, click here. The download is 26MB so a modem is probably not the optimal approach. When the download completes, the image file should automatically mount on your Mac desktop. If not, double click on the .dmg file to open the folder. Now double-click on php-4.3.10.pkg. Let it check the compatibility of your Mac. Then select your default drive, provide your admin password, and PHP will be installed. When the installation completes, you can eject the image file from your desktop.

[Update: On some machines, a minor adjustment in the Apache configuration file may be necessary to support PHP. Open a terminal window (Go to Applications/Utilities and double-click on Terminal icon). Type sudo su and press enter to switch to the root user. Type cd  /etc/httpd and enter to move to the Apache config directory. Type pico httpd.conf and enter to load the Pico editor and edit the Apache config file. Be careful here! Press Ctrl-W, type php4, and press enter to search for the word "php4." You should be positioned on a line which begins #LoadModule php4_module .... If there is a pound sign (#) at the beginning of the line, we need to remove it. Don't hit delete! If you did, just backspace over the weird characters. Position the cursor under the # sign and press Ctrl-D. Now press Ctrl-W and enter to find the next occurrence of php4. Do this a couple times until you get to a line that begins #AddModule mod_php4.c. If there is a pound sign (#) at the beginning of the line, delete it by positioning the cursor under the # sign and pressing Ctrl-D. That's it for the changes. Now save the file by pressing Ctrl-X, then Y, then enter. Exit gracefully from the terminal window by typing exit and pressing enter, repeat it, and then Command-Q. Now we need to stop and restart the Apache Web Server for the changes to take effect. Click on the Apple icon in the upper left corner of the screen and choose System Preferences. Double-click on the Sharing folder. Deselect Personal Web Sharing by clicking on the check mark beside this option. Wait for the web server to stop. Then select Personal Web Sharing by clicking on the check mark box beside it again. Wait for the web server to start up again, and then close System Preferences by pressing Command-Q. ]

Now let's be sure PHP installed properly. Make sure your Apache web server is running (consult the previous column on Apache if you need further assistance or a refresher course). Now open TextEdit in your Applications folder. Change the editor to plain text format by clicking Format, Make Plain Text. Now type the three lines shown in the left inset ending each line with a carriage return. Then save the file to your desktop as test4u.php in Unicode (UTF-8) format. When prompted whether to append .txt to the file name, choose "Don't append." Now use Finder and click on your local hard disk. Then navigate to /Library/WebServer/Documents. Now drag and drop test4u.php in this folder. Using your web browser, type in this address: http://localhost/test4u.php. You should see a PHP-generated page displaying everything you ever wanted to know about your computer. If not, recheck to make sure your web server is running and that you don't have a typo or missing semicolon in your test4u.php file. If all else fails, try reinstalling PHP or call your favorite Mac guru (not me!) for a little assistance. [Update: Once you've tested your system, move the test4u.php file out of your web site folder to prevent misuse.] Congratulations. You've just earned your first programming merit badge!

Now it's time to install our first PHP application, phpMyAdmin. This is a complete web front-end for MySQL that let's you create, delete, modify, and do just about anything else to any and all MySQL databases. Here are a few warnings to get you started. As with any powerful tool, be careful. Don't muck around in the database called mysql or MySQL itself may come to a screeching halt. If you want to experiment, then create your own database and play there. Leave databases connected to applications you need alone. And, finally, here's a word about security. We plugged a hole in MySQL to keep outsiders out yesterday. When you install phpMyAdmin, you're letting them right back in unless you complete all the steps outlined here. You also will want to RTFM (read the manual) and decide for yourself whether additional security measures are warranted because of where your machine is placed. If you are sitting in the middle of a fraternity house and half of your brothers belong to the 'Nerd of the Month' Club, all bets are off. If you're in a private residence with fairly trustworthy relatives around, the security outlined here is probably enough to keep someone from hacking into your new Mac. End of Sermon.

By now you should know the drill fairly well. First, make sure your Mac is running Mac OS X v10.3 and is up to date with Apple patches. Second, we need to download the phpMyAdmin software. Go to the Sofotex web site and click Download Now. Be patient for a few seconds, and your download should begin automatically. If not, choose a mirror site from the list. This will deposit a phpMyAdmin tarball (.tar) on your desktop which should decompress into a folder named phpMyAdmin-2.6.1. If not, double-click on the tarball to decompress it. Now let's open the folder by double-clicking on it. Find the config.inc.php file and Control-Click on it and choose to open it with TextEdit. When the file opens, choose File/Print and print just pages 1 through 4 of the file. While your file is printing, click on the Apple, choose System Preferences, click on the Sharing folder, and then click on the words "Personal Web Sharing." Be careful not to deselect the option or you'll shut down your web server. Now look at the bottom of the display and write down the IP address that's shown after the words "View this computer's website at http://." Press Command-Q to close your System Preferences window. Click in your TextEdit window and then press Command-Q to close it as well. Now close the phpMyAdmin-2.6.1 folder. Click once on the folder's file name and rename it to php and press enter. Now we're going to drag the folder to its permanent home. Open a Finder window, click on your local hard disk icon, and move to /Library/WebServer/Documents. Now drag and drop the php folder from your desktop into the Documents folder, which is as you'll recall the root folder for your computer's web server. Open a web browser, and go to http://localhost/php/. Assuming your Apache web server and your MySQL server are running, you should see a snazzy phpMyAdmin web page with at least the name of your mysql database in the left column and a bunch of nasty, red security messages at the bottom of the screen. If not, check to be sure Apache and MySQL are both running. As the red messages say, YOUR SYSTEM IS NOT SECURE at this point so don't be quitting just yet. Close the web browser, and let's plug the security hole. You're gonna need those four pages you printed and the IP address you wrote down.

We're going to secure your computer now so PAY ATTENTION! We need to edit a few lines in the phpMyAdmin config file to tell it to only let you run the program. Otherwise, anyone with a web browser can type your IP address and then /php to do exactly what you just did. Not good! Move back to your Finder window which should be positioned in the /Library/WebServer/Documents folder. If not, move there again. Then double-click on the php folder to open it. Find the config.inc.php file and Control-Click on it and choose to open it with TextEdit. Now let's look at your printout and mark what needs to be changed. Then you can make the changes CAREFULLY with TextEdit and save the file (Alt -S). First go to page 2. At the top of page 2 should be a line that says $cfg['PmaAbsoluteUri_DisableWarning'] = FALSE;. We want to change only the word FALSE to TRUE. Don't mess up the existing punctuation and quotes! Now go to page 4. About two-thirds of the way down the page are several lines that look like the following. Be very careful in searching for these because there are two more sets of identical lines further down in the configuration file. We don't want to change those.

$cfg['Servers'][$i]['AllowRoot'] = TRUE; // whether to allow root login
$cfg['Servers'][$i]['AllowDeny']['order'] // Host authentication order, leave blank to not use
= '';
$cfg['Servers'][$i]['AllowDeny']['rules'] // Host authentication rules, leave blank for defaults
= array();

Now, here's what it should look like after you fix it except you need to replace the IP number 192.168.0.112 with the number you wrote down on your piece of paper.

$cfg['Servers'][$i]['AllowRoot'] = TRUE; // whether to allow root login
$cfg['Servers'][$i]['AllowDeny']['order'] // Host authentication order, leave blank to not use
= 'deny,allow';
$cfg['Servers'][$i]['AllowDeny']['rules'] // Host authentication rules, leave blank for defaults
= array('deny root from all','allow root from localhost','allow root from 192.168.0.112',);

I'm not even going to tell you how important the correct punctuation is, but if you screw it up, you'll know shortly. Once you save the changes, open a web browser, and go to http://localhost/php/. If this didn't work, try http://192.168.0.112/php/ using your own IP address, of course. Do you finally see the same lovely phpMyAdmin? If so, at least you can get in. If not and you see an Access Denied message, check for typos and make sure you put in the correct IP address. Once you can access phpMyAdmin successfully, then we need to make sure no one else can (from anywhere). If you have another machine on your network, use a web browser to go to http://192.168.0.112/php/ substituting your IP address from your trusty sheet of paper again. You should see the phpMyAdmin heading with an Access Denied message. If you have no other machines on your network, visit a friend and try to access your phpMyAdmin site in the same way using your Internet IP address (if you have a firewall/router, you first need to configure it to pass port 80 traffic to your private IP address). You still will see a big red message saying you're using a root account for MySQL with no password. While this is true, it is only accessible while sitting in front of your Mac and NOT from elsewhere assuming you carefully followed the MySQL tutorial yesterday. phpMyAdmin unfortunately isn't smart enough to know the difference. If you want to make this message go away (and that's all we're doing!), open main.php in the /Library/WebServer/Documents/php folder using TextEdit, search (Command-F) for the first occurrence of the word root, and replace it with toot (or any other word but root), and save the file (Command-S). Now close your web browser, reopen it, and go to http://localhost/php/ or http://192.168.0.112/php/ using your own IP address. Whew! Once again you've passed with flying colors.

That's it for today. In our next session, we'll tie up all the loose ends, do a little experimenting with phpMyAdmin, and I'll provide some sample code and point you to some great books to get you started with your new PHP/MySQL programming career. And we'll share some great news about the future of our ISP-In-A-Box series. Thanks for visiting. Have a great weekend!

ISP-In-A-Box: The $500 Mac mini (Part III, MySQL)

This is the third installment in our five-part series on building a full-featured Internet hosting server with a Mac mini. On the first day, we covered hardware requirements and installation and operation of the Apache Web Server. Day two added mail services including SMTP, POP3, and IMAP servers. Today we begin the fun part of being the master of your own Internet universe with the installation of the MySQL data base management system. Why would you want a data base server in general and MySQL in particular? The short answer is that installation of MySQL today and PHP tomorrow truly opens up the Internet universe and gives you access to literally hundreds of fantastic, free, commercial-quality applications. These include blogs such as WordPress (which you are reading now), photo galleries such as Coppermine, content management applications such as phpWebSite, discussion boards such as phpBB2, project management apps such as PHProjekt, customer service systems such as PHP Support Tickets, polling and surveying systems such as phpESP and PHPsurveyor, wikis such as PhpWiki, mailing lists such as phpList, and other terrific applications including PHPauction, phpCOIN, phpFormGenerator, WebCalendar and on and on the list goes. Plus, you can build your own databases and applications to your heart's content without spending a dime for the software or the tools. So let's get started.

Our game plan is to get MySQL installed on your Mac today and give you the rest of the day to play with it. We're going to install MySQL 4.1 even though version 5 is also available. The reason is that most ISPs still run version 4.1, and many of the applications we listed above are not yet compatible with version 5. Then tomorrow we'll add PHP and PHPmyAdmin to the mix, and you'll never have to stare at a MySQL command prompt again... unless you want to. But, it's fun once so just play along. First things first. We need to download the correct version of MySQL to match the correct operating system and correct version of that operating system. This began as a Mac mini project so we're assuming you're running Mac OS X v10.3 aka Panther. If not, you need to make the necessary adjustments as we go along. If you haven't already done so, load the latest Apple patches on your system so that you are current before we begin this installation. Now choose a mirror site that's close to you from this list and download the MySQL installer to your desktop. Once the .dmg image file downloads, it should automatically mount on your desktop. If not, double click on it to mount it now. In the image folder, there are two package files, a preference pane installer to install MySQL in your System Preferences tray, and a readme file. Drag the readme.txt file to your desktop for safekeeping.

Now we're ready to begin the MySQL installation. First, we will install MySQL. Next, we'll install the automatic startup package which is responsible for making sure the MySQL daemon always starts up when you boot up your Mac. And finally, we'll install the new preference pane to start and stop the MySQL server. To get started, double-click on the mysql-standard package. Answer the prompts, choose your default drive, agree to the license, and enter your administrator password. If there is a problem during the installation, consult the readme file. Otherwise, you'll see a message in a minute or so indicating that the installation was successful. Now double-click on the MySQLStartupItem package, choose your default drive, enter your administrator password, and wait for the installation to complete. Lastly, double-click on the PrefPane icon, tell it to install for you (the administrator) only, and wait for the installation to complete. Just to be sure everything went according to plan, restart your Mac.

When your Mac comes back to life, click on the Apple icon in the upper-left corner of the screen, choose System Preferences, and then click on the MySQL icon in the bottom of your System Preferences tray. It should show MySQL running with a check mark next to the option to automatically start during system startup. If not, make the necessary corrections to start MySQL and to assure that it automatically starts in the future. The MySQL installation is now complete, but MySQL is not yet secure! So ... keep reading.

Don't ask me why but MySQL's default installation sets up anonymous and admin user accounts that are wide open (i.e. password-free) for all the world to hack, and they have. Kinda reminds you of another company in the great Northwest, doesn't it. If you don't plug this security hole, any person that discovers your IP address can totally destroy every MySQL database you build and take remote control of your machine! In short, you're toast! It should be noted that the anonymous and admin accounts for localhost access (which are separate accounts) are also password-free, but this shouldn't be a problem so long as you have control of your physical machine. So let's fix the mess and set up MySQL so it's easy to access (for you and your web server, not the world). Open a terminal window by choosing the Terminal application in your Applications/Utilities folder. Type sudo su and press the enter key.

You now can connect to your MySQL server by typing /usr/local/mysql/bin/mysql at a bash command prompt. Let's do it now. You should then see a MySQL command prompt that looks like this: mysql>. First think up a very secure password for remote access to your MySQL server (you're never going to use it probably so make it a good one). Now you're ready to type the following command substituting your new password for the word "secret" and don't forget the two pairs of single quotes and the semi-colon on the end of the command:

  • update mysql.user set password = password('secret') where host<>'localhost' ;
  • When you press the enter key, MySQL should report that two records were changed. If not, try again. Cut and paste the command above if you have to. Once you get the "two records changed" message, double-check your work by typing this command:

  • select host,user,password from mysql.user ;
  • MySQL should list four accounts. The two localhost accounts should have blank passwords, and the other two should have passwords that you can't decipher. If not, repeat the drill until you get it, or you might just as well never use MySQL. My apologies for the diatribe. You'll thank me in ten years when you never get hacked. Here are the last two commands to enter in MySQL for now. The first makes certain that your changes get written to disk, and the second gets you out of MySQL gracefully. Once back at a bash command prompt, type exit and enter twice and then Command-Q to close the terminal window.

  • flush privileges ;
  • q
  • Your homework for tonight is to take a look at the MySQL documentation so that you get a feel for what can be done with a relational database. Using Safari or any web browser, open the MySQL documentation by entering this address: file:///usr/local/mysql/docs/manual.html#Tutorial . To get back to the MySQL command shell: open a terminal window, type /usr/local/mysql/bin/mysql and press enter. Have fun! Don't forget to end your commands with a semicolon, or MySQL just sits there. Don't forget to exit gracefully (q) when you're finished.

    Feb. 9 Supplement. Several common questions have arisen since this article first appeared. I wanted to address them in the body of the article for the benefit of new visitors who might not read the comments.

    Missing Preference Pane. On some older Macs (apparently not Mac mini's), there is no Preference Pane option in the MySQL installation folder to install in System Preferences. This is not a big deal. All this preference pane does is allow you to stop and start MySQL. You can do the same thing from a Terminal window (opened from Applications/Utilities):

  • To start MySQL manually: sudo /library/startupitems/mysql/mysql start
  • To stop MySQL manually: sudo /library/startupitems/mysql/mysql stop
  • To restart MySQL manually: sudo /library/startupitems/mysql/mysql restart
  • Uninstalling MySQL. Here are the steps. Don't skip any! You cannot undo these deletions!! All your data will be lost, too!!! If something goes wrong in a step, do not go to the next step. Send me an email. First open a Terminal window (opened from Applications/Utilities):

  • Switch to root user access: sudo su
  • Provide admin password if prompted: type your password
  • Move to the folder where MySQL is stored: cd /usr/local
  • List the contents of the folder: ls
  • Write down the exact file names of all files beginning with mysql : there should be two, a file and a directory
  • Stop MySQL manually and make sure it says it is stopped: sudo /library/startupitems/mysql/mysql stop
  • Delete the MySQL symbolic link file: rm mysql
  • Delete the MySQL directory and subdirectories using the long file name you wrote down above: rm -rf mysql.standard.rest.of.filename
  • Move to the Receipts folder: cd /library/receipts
  • Delete the MySQL directory and subdirectories using the long file name you wrote down above: rm -rf mysql.standard.rest.of.filename
  • Move to the startup folder: cd /library/startupitems
  • Delete the MySQL startup directory: rm -rf mysql
  • Delete the other possible MySQL startup directory: rm -rf mysqlcom
  • ISP-In-A-Box: The $500 Mac mini (Part II, Mail Services)

    We began our five-part series on building a full-featured Internet hosting server with a Mac mini yesterday and covered the recommended hardware for the server as well as basic instructions for setting up an Apache Web Server. Today we’ll show you how to turn your Mac mini into a full-blown mail server with SMTP, POP3, and IMAP support. Before doing that, let me first define what SMTP, POP3, and IMAP are. And then I want to offer a word of caution about why setting up these services (especially POP3 and IMAP) for most folks is probably a bad idea.

    SMTP or Simple Mail Transfer Protocol is a collection of services to send email messages between servers. It also accepts messages from mail clients for delivery to others. Messages are retrieved with a mail client which "talks" to either a POP3 or IMAP server which manages the flow of incoming messages between an SMTP server and the mail client. While there are exceptions, the fundamental distinction between a POP3 client and an IMAP client is that POP3 clients download messages and manage them on a local machine while IMAP clients download copies of messages which are generally stored on a server. At the risk of oversimplifying, if you have one computer and one email account, POP3 is more than adequate. If you have multiple computers that all need access to your email messages or if you need web access to your email messages, IMAP is probably a better choice because it is more robust particularly in handling deletions of messages from a variety of locations.

    Rather than telling you not to install an email server, let me try to define when it would be appropriate and leave the rest to you. Every ISP on the Planet provides SMTP services for its customer base. If you have Internet access, you generally also have SMTP services to handle delivery of your outgoing email messages. One advantage in setting up your own SMTP server is you will always know its address or domain name. If you travel extensively or spend lots of time in Wi-Fi HotSpots of different vendors, then SMTP services for outgoing mail can be painful because you generally have to reconfigure your email client to tell it the address of your SMTP server before you can send or reply to email. This is not always the case, however. Most modern WiFi HotSpot routers now transparently reconfigure your SMTP settings when you connect to their services. And having your own SMTP server doesn’t always mean you can send email because more and more ISPs are blocking SMTP activity from downstream computers (i.e.. computers located inside your ISP’s firewall and routers) as a way to better control the proliferation of SPAM.

    Almost every ISP on the Planet also provides POP3 mail services for customers, and most provide IMAP and webmail access as well. In addition, for mail delivery and storage, there are numerous other free services including Gmail from Google, HotMail from Microsoft, and Yahoo Mail from Yahoo as well as low-cost vanity email providers such as NetIdentity.com. Unless email between numerous users in your local area network is significant and uploading and downloading of messages to and from an ISP causes inordinate delays in the delivery of email, I can think of no sound reason to deploy either a POP3 or IMAP server on your local system. And there are some very good reasons for not doing it. First, it all but requires that you have a good grasp of DNS principles and that you properly configure your mail domain. If you’re saying, "What’s that," then you definitely do not need a POP3 or IMAP mail server. Second, if you don’t know what you are doing with DNS and your POP3 and IMAP settings, you run the very real risk of losing all of your incoming mail or having it bounce back to the senders. Third, most ISPs back up their servers fairly regularly. Do you plan to do the same? It’s your email! Finally, mail server services can be processor intensive and eat into your available resources. Keep in mind that these services have to run regularly to determine whether there is incoming or outgoing mail and, if so, to process it. Is it worth the computing resources to duplicate a service that skilled personnel already handle for free at your neighborhood ISP? End of lecture.

    So you want to be a mail administrator. Great! Assuming you’ve mastered DNS (which is beyond the scope of this tutorial … and me), setting up SMTP and optionally POP3 and IMAP services couldn’t be easier on the Mac mini. Step 1: Go to this web site or this one and download Postfix Enabler. Step 2: Print a copy of the web page while you are there. This is the installation and operating instructions. Step 3: Decompress the archive and drag the Postfix Enabler icon to your Applications folder. Step 4: Run the application and provide your Admin password. Step 5: Click the Enable Postfix button. You now have a fully functional SMTP server. Step 6: If you want POP3 or IMAP servers enabled, reread the warnings above (hint!), and then read the Postfix Enabler documentation for installation and configuration instructions. Step 7: Send the author a small donation. Postfix Enabler is shareware. Having dabbled in shareware myself once upon a time, I can tell you it’s one of the best things that ever happened to keep the computer industry honest and competitively priced.

    Note: Unlike Windows machines which all have their special quirks, all Macs pretty much work the same way so everything we’re discussing will work just as well on an iMac, or Powerbook, or Power Mac G5, or eMac, or iBook so long as you’re running an up-to-date version of OS X v10.3, aka Panther. If you have a Mac mini, then you have OS X v10.3. If you have a different Mac and you’re using an earlier version of OS X, then pretty much everything is different insofar as mail services (even the SMTP server is different) so you can stop reading now.

    To test your new SMTP server, start up your mail client and reconfigure your client’s SMTP server settings to point to 127.0.0.1. Now send a message you don’t mind losing to someone you know and ask them to reply. Or just send a message to yourself. Wait a few minutes and refresh your mailbox. Keep in mind that a number of ISPs block all SMTP-generated email messages from end-users (that’s you!). If it doesn’t work, it’s probably your ISP that’s the problem, not Postfix. I told you not to do it. Didn’t I?

    In our next installment, we really will be installing something you need, the MySQL data base management system, one of the fastest and most reliable DBMS products in the marketplace. It also happens to be free for most purposes. What can you do with MySQL? Just about anything. Take a look at our main web page at mundy.org. It is completely generated from a MySQL database. Or visit one of our beach webcam sites at Pawleys Island or Surfside Beach. All of the tide, sunrise, and sunset data for these sites is generated from a 100-year table of data stored in, you guessed it, a MySQL database. So join us back here tomorrow.

    ISP-In-A-Box: The $500 Mac mini

    Today we begin our five-part series on building a full-featured Internet hosting server with a Mac mini. If you’ve followed our previous advice and are considering a move to a hosting provider for your web sites, then this series will show you how to build the perfect staging server, a place to experiment with new code before moving it to a production environment. Over a year ago, we undertook a similar project on the Windows XP platform. The difference in performance, security, and ease of deployment on the Mac platform is the difference in night and day so you’re in for a treat! For those unable to afford the move to a hosting provider at this time, you can use a Mac mini as your host for the time being. Functionally, there’s nothing a hosting provider would give you that can’t be replicated for free on the Mac mini. Other than bandwidth and slightly better performance, the Mac mini will provide an almost identical hosting environment to what you’d be using with a commercial hosting provider. In fact, we recommend installing application versions which match what most reputable hosting providers use, and we will do that here. If you later decide to make the move to a hosting provider, everything you’ve built on your Mac mini can be transferred with ease. Listed below are the pieces we’ll be putting into place over the next week or so to complete our ISP-In-A-Box project:

  • Apache 1.3 Web Server
  • Postfix Mail Server (SMTP, POP3, and IMAP)
  • MySQL 4.0.23
  • PHP 4.3.10 and PHPmyadmin 2.6.1
  • WebMin, Pico Editor, CronTab and other goodies
  • Our focus today will be on the hardware and web server software you’ll need for this project, and then we’ll get the Apache Web Server up and running to host your first two web sites. Luckily for you, Apple has made this project incredibly easy … and cheap. You’ll need a Mac mini which includes Mac OS X and FreeBSD ($499). Like Linux, FreeBSD is another UNIX derivative so most of the rock-solid Internet applications available for Linux have also been ported to FreeBSD. And, also like Linux, most of these applications are free at least for non-commercial use. Unlike Microsoft where security has been an afterthought and Linux where you have to track down patches and dependencies yourself, Apple takes security seriously and automatically notifies you when patches become necessary to keep your machine safe and secure. One button click and an admin password, and you’re up to date with the latest fixes and enhancements. If you’re serious about having web applications accessible from the Internet, there really are no sane options other than the Mac platform or contracting out your web hosting. Then again, perhaps you need another full-time job in which case Linux or Windows servers will gladly suck up every free minute of your day.



    Hardware. Since the Mac mini only has one RAM slot and because Apple has made Mac mini hardware upgrades difficult (but not impossible), you may want to consider at least bumping the machine up to 512MB ($75) when you initially order it. This will almost double the performance of the box for applications such as those we’re going to be deploying. Extra RAM is particularly important once we get all of the ISP functions (shown above) running simultaneously. The other option that’s too inexpensive to pass up is increasing the hard disk size from 40GB to 80GB. For $50, you’ll never be sorry. If $499 is your absolute budget, then fine. Everything outlined here will chug along on a $499 Mac mini. If you can scrape together another $125, you’ll have a much more capable system down the road when you really start exercising the server capabilities of the Mac OS X platform.

    Unlike Microsoft, which cripples Windows XP Home Edition by not including a web server, Apple has taken just the opposite approach with Mac OS X, the operating system which is included with your Mac mini. Because Mac OS X is built on top of the FreeBSD platform, Apple has included most of the FreeBSD development tools in its software distribution. Enabling the Apache Web Server on your Mac mini may just be the easiest thing you ever do on the computer. Click on the upper left corner of your display and then choose System Preferences. When the System Preferences window appears, click on the Sharing folder under Internet & Network options. Under the Services tab, place a check mark in the box beside Personal Web Sharing. If the system won’t let you select this option, click the Lock and enter your administrator password. If you want people on the Internet or your local network to be able to access your web site, you also need to enable Personal Web Sharing under the Firewall tab. You do have your firewall enabled, don’t you? If not, do it now! Once you complete these steps, open your web browser and enter localhost as the destination address to find. You should see the Test Page for the Apache web server with the Apache logo. Congratulations! You’re now a webmaster.

    Actually, your Mac mini is now hosting at least two different web sites. The main web site which is accessible at localhost, 127.0.0.1, or your Internet IP address is the one we’ve already accessed. If you open a Finder window and select your local drive icon, this will move you to the root directory. Then choose Library, Webserver, and Documents to move to the directory where HTML pages for your main web server are stored. The default web page is index.html or index.html.en if you’re supporting multiple languages and English is your computer’s native tongue. There’s also a web site for each user account on your Mac. Documents for these sites are stored in the Sites folder of your home directory. You can access this web site at the following address: http://localhost/~yourname where yourname is the account name you set up when you first turned on your Mac. When you access this site, Apple even provides instructions for building your first web page. Your personal web page can be accessed from the Internet with an address such as http://nnn.nnn.nnn.nnn/~yourname where nnn.nnn.nnn.nnn represents the IP address provided by your ISP.

    Finally, you’re probably whining because most folks don’t access web sites with an IP number and most ISP’s assign dynamic IP addresses which are always changing. Right you are to complain, on both counts! Here’s what you need. First download DNSupdate and install it on your Mac. This software regularly talks to a DNS server to tell it what your current IP address is. Next, set yourself up a dynamic DNS name on DynDNS.org. Once you complete both these steps, people can access your web site on your home network using a domain name just like mine. Using a web browser, type in wmundyhome.dyndns.org to see how it actually works.

    Tomorrow we’ll get your email server up and running on the Mac mini with about the same amount of effort it took to activate Apache. Until then, here’s hoping you enjoy your first day as a webmaster. Click here to read the rest of the articles in this series.

    Web Hosting (Is Not) For Dummies

    There’s nothing quite like discovering that you really can build your own Apache web server and host your own web site even running Windows XP Home Edition. Having done that, the next question you need to ask yourself is why anyone would want the everyday chore of wrestling with security patches, dependencies, libraries, compilers, and on and on unless you just happen to do this sort of thing for a living. Assuming you’re still with me, the next question becomes where to turn for web hosting services. Typing "web hosting" into Google returns just over 25 million hits so that’s probably not the best approach. Having used five fairly good web hosting companies over the past two years, I thought it might be more helpful to sketch out what to look for rather than just providing an outright endorsement of a particular vendor, but we’ll get to that. To begin, here’s a short list of the Top 5 Things to Look For in a Web Hosting Provider.

    Reliability means so much more than 99.9% uptime. Is there a guarantee? What do you get if the system isn’t up 99.9% of the time? For many businesses, the guarantee isn’t nearly as important as finding a service that really, really is up 99.9% of the time. After all, you really don’t want your $20 back. You want customers to be able to order from or see your web site. So here’s what to look for in reliability. Does the provider use the latest and greatest web server hardware? Visit Dell and compare. Does the provider use multiple pipes to the Internet from different companies? Is the provider hosting from a network operations center that has backup power? Does the provider make system backups? Many don’t! Does the provider publish a phone number to call when the servers go down? Is the provider using the latest versions of Linux and/or Windows Server?

    Performance also matters. The latest hardware and big pipes to the Internet help but, once you leave the mom-and-pop operations behind, most providers meet these two criteria. The true measure of performance has more to do with how many users share a server with your domain, what types of customer applications are running on that server, and how carefully the provider monitors activity on your shared server. How do you know? The short answer is you really don’t until you sign up. So look for a provider that gives you short-term rates (preferably month to month) and a 30-day money-back guarantee. Having said that, even with good providers, the addition of one disreputable customer who runs a hundred spam scripts an hour will cause immediate problems for you.

    Response Time Solving Problems. There are two pieces to this puzzle: how quickly can you get word to the provider that your server has croaked and how quickly can they fix it. Good providers have multiple ways for customers to report problems: through the web, pagers, faxes, and phone calls. If your provider only offers a web form, there’s probably a reason. How quickly a provider fixes problems is quantifiable, but it will be unusual for you to know about most issues other than your own. The bottom line on response time is pretty simple. If you’re having frequent outages that are forcing you to worry about response time to fix problems, your provider has problems. Look elsewhere!

    Scope of Services. The most important feature you can have with your domain hosting account is a quick way to move to another provider when things go south. If you use MySQL databases and cron scripts, backing up your own data (assuming you can get access to it) is painful to put it mildly. If a provider uses cPanel as the shell for your accounts, there are tools that will let your next provider grab virtually everything in your account and transparently move it to your new provider’s server. So, unless you have little more than static web pages which you back up regularly, look for a provider that runs the latest (commercial) version of RedHat Enterprise Linux with Web Host Manager (WHM) and cPanel for managing your account. The standard mix of applications should include POP and IMAP email accounts, web mail, MySQL and PostgreSQL data base management systems, PHP and PHPmyAdmin, and SpamAssassin. Virtually all the providers give you FTP access to upload and download materials for your web site. Some provide Secure Shell access (SSH) for an additional fee, but this exposes them to additional security risks so don’t count on it. If your needs are more for creative web tools such as e-commerce, project management, customer service and support, photo galleries, discussion forums, or blogs, then you also should look for a provider that includes Fantastico which makes complex script installations a breeze. For example, this WordPress blog was installed, configured, and ready for use in less than five minutes using Fantastico.

    Cost. Luckily for us, it’s a buyers’ market for web hosting services. So long as you get 25 million hits on the words "web hosting" in Google, cost will be the least of your worries. To host one or a few domains should rarely cost more than $10 a month with plenty of bandwidth to support normal access. You do pay for bandwidth which is measured with virtually all reputable providers. If a provider advertises "unlimited bandwidth" and the price is too good to be true, it probably is. Either the provider will terminate your account when you begin using excessive bandwidth (by their definition, not yours) or the performance of your site will be so miserable that it won’t matter how much free bandwidth you have. Unless you’re hosting something illegal (such as music) or pornography, both of which most reputable providers frown upon, 20GB of monthly bandwidth will usually suffice for all but the most heavily traveled web sites. Another issue to explore, of course, is the cost of switching hosting plans or upgrading bandwidth as your requirements grow.

    Bottom Line: WestNIC.net gets my vote for the best overall hosting company. And an honorable mention no longer goes to HostDime.com. Since leaving HostDime a year ago, many of my colleagues have followed so things appear to be headed in the wrong direction there. Your mileage may vary.