
|
You may think you are one with the Interwebs, but until you actually create a website, you are merely part of the Interwebs. Follow this tutorial, and you will learn how to become one in about a billion, the exclusive club of people who host sites of some sort.
Hosting an HTTP server used to be an arduous task, but Mac OS X makes it easier than ever. We recognize that there is a built-in Web Sharing feature that allows you to create a server with one click, but we will teach you how to make a more advanced server that can handle server-side scripting languages like PHP.
Difficulty Level:
Medium
What You Need:
>MAMP (free, www.mamp.info)
>A DynDns account (free, www.dyndns.com)
> Access to your router to forward ports (in other words, a home network you control)
> A Mac that’s on and connected to the Internet all the time (in other words, if you try this with a laptop, your site will be down whenever you laptop is off or disconnected)
>Optional: a CMS like Drupal (free, drupal.org) or Wordpress (free, www.wordpress.org)
1. Install MAMP
MAMP (an acronym for Mac, Apache, MySQL, PHP) is an open-source platform for hosting a website on a Mac. Download the MAMP disk image, open it, and drag the MAMP folder to the Applications folder to install it. Then, browse to the /Applications/MAMP folder. You should see something akin to what is in this screenshot.

We like saying the word MAMP repeatedly. It’s a fun word.
This is the control center for your entire installation. Any websites you create will go here, and all the configuration files for your server will go here as well.
2. Configure MAMP
First, open the MAMP.app file in the /Applications/MAMP folder. This will start the HTTP server. Then, click Preferences. The first thing you need to do is deselect “Stop Servers when quitting MAMP” and “Check for MAMP PRO when starting MAMP.” This way, you don’t have to keep the application running all the time to keep the servers on.

Try it: “MAMP, MAMP, MAMP.” It’s just fun to say.
Next, go to the Ports tab, and click the button that says, “Set to default Apache and MySQL ports.” Sticking to standards is always best, because if you leave it as port 8888, for example, your URL will be something like www.example .com:8888, which is annoying.
3. Sharing is Caring
Now, go to System Preferences, and click the Sharing tab. Check File Sharing, but then click the Options button. Make sure “Share files and folders using FTP” is selected. FTP is generally considered the standard for editing websites remotely, and if you plan to use a tool like Dreamweaver or Coda to edit the HTML code, they use FTP (and its more secure sibling, SFTP) to manage sites. Click Done.

Next, make sure Web Sharing is deselected. If it’s selected, the Apache server that comes with your Mac will conflict with the one that MAMP has just installed. Finally, you should check the box for Remote Login, because controlling your computer with SSH is the easiest way to restart the server remotely (for more about SSH, visit www.maclife.com/ssh_surf).
4. Go for Ports, not Starboard
If you plan on accessing your website outside of the computer that is hosting it, and you have a router or firewall, you will need to forward the ports for HTTP to your computer. The way to do this is different for each router, but the basic process is the same. First, go to System Preferences > Network. Write down the local IP address that is shown.

Find the local IP address under Status, and write it down.
Then, go to Port Forward (www.portforward.com), scroll down, and click on your model of router. On the next page, atop the giant list of services, you’ll see your external IP (different from your local IP), and write that down too. Find Apache is the list of services and click it. On the next page, enter your local IP address as noted earlier, and follow the resulting instructions to forward the proper ports on your router.
5. Set up your Domain
Technically, this is an optional step, because you can already browse to your site at http://[your IP address here], but unless you have a photographic memory, chances are you aren’t going to remember a string of pseudo-random numbers. So you can buy a domain at a site like GoDaddy.com or Yahoo Domains (smallbusiness.yahoo .com/domains), but you can also register for a free domain at a site like DynDNS.com, with a little less control over what your domain actually is.

To do this, go to www.dyndns.com/services/dns/dyndns/ and click the Get Started button. In the Hostname area, type in a name you can remember, and then choose what comes after the dot in the drop-down. (We went with ourname .dynalias.com.) For Service Type, leave the default Host With IP Address selected. Your external IP goes in the IP Address box, and there’s also a button to auto-detect it—it should match the external IP you wrote down in step 4. Click the Add To Cart button and check out; this service is free, so it won’t ask you for credit card info, but you do need to create a user account at DynDNS.com when prompted.
6. The DynDNS Updater
DynDNS Updater will keep your host name pointed to your ever-changing external IP address.
Head to www.dyndns.com/support/clients/mac.html and download the DynDNS Updater application. Load the DMG file, and drag the application into your Applications folder to install it. Launch DynDNS Updater, login with your DynDNS account credentials, and you’ll see your account name in the sidebar. Click the right-facing arrow to show your website, and select it. Check the box labeled “Enable updating for this host,” and you should be good to go. Now, if your router’s ports are forwarded properly, you can browse to your site at the domain you just created.
7. Install a CMS
This is optional, but a CMS, or content-management system, is incredibly useful if you want to host your own blog. The most popular ones are WordPress and Drupal. To install WordPress on your system, first download the WordPress ZIP file. Unzip it and drag the WordPress folder to /Applications/MAMP/htdocs.

After changing the DB_USER and DB_PASSWORD names.
Now, browse to that WordPress folder, and open the file wp-config-sample.php in a text editor such as TextEdit. You’ll notice there is a space for DB_NAME, DB_USER and DB_PASSWORD that have things that you need to fill in. Replace ‘usernamehere’ with ‘root’ and ‘yourpasswordhere’ with ‘root’ as well. Now we need to create a database, so we can fill in ‘putyourdbnamehere.’ Leave the file open in your text editor for now.
8. Create a Database
Open the MAMP.app application, and click Open Start Page, which launches the MAMP start page in your default browser. In the toolbar along the top of that page, click “phpMyAdmin.” Under “Create new database,” enter a name for the database, and click Create.
Create your database name here.
Now, come back to the wp-config-sample.php file that’s open in your text editor, and replace ‘putyourdbnamehere’ with the name of the database you just created, enclosed in single quotes. Finally, save the modified file as wp-config.php.
9. That’s It
Now, you can browse to http://localhost/wordpress, and the WordPress Install Utility will guide you through the rest of the process. In general, you can save any file in the htdocs folder, and you will be able to access it from the Web—think of it as a file browser for the Web. Instead of browsing to htdocs on your computer, you’re browsing to your URL, and then entering the file’s path. Files that the browser can’t interpret, like music or videos, will be downloaded when you browse to them, and files that can be interpreted will be displayed. Beware of trying to download too much information from your home-rolled Web server or having too many people browse to it at once—your computer will heat up and might explode or something. If you plan on truly taking over the Internet, get someone else to host your website.