Serve local web pages via name not IP number Michigan

Learn how to serve web pages locally via name instead of IP address.


1 . Local Companies

DOG GUARD OF MICHIGAN
810 923-6289
906 N Oak
FEnton, MI
Gamesagalore Xbox 360 Repair
734-713-7502
22525 Ecorse Rd
Taylor, MI
ABC Warehouse
231-929-2800
3500 Marketplace Circle
Traverse City, MI
The Pod Drop - iPhone / iPod Repair
866 929-3767
4 metro Detroit Repair Center Locations
Washington, MI
Hunter Audio Inc.
906 226-7700
4125 US Hwy. 41 West
Marquette, MI
Burnzi's Surveillance Spy Outlet LLC
248-393-5600
465 Elizabeth Lake Road
Waterford, MI
Ray Lighting Centers
(586) 771-2211
27311 Gratiot Ave
Roseville, MI
Win's
(810) 250-2501
G3347 Richfield Rd
Genesee, MI
Rockwell International Corporation
(248) 435-1139
2135 W Maple Rd
Troy, MI
Rockwell International Corporation
(248) 435-1295
2135 W Maple Rd
Troy, MI

2 . Serve local web pages via name not IP number

provided by: 


Today's hint is about OS X 10.5's built-in Web server, and how you can make it easy to access sites you're running off that server. In case you weren't aware, the built-in OS X web server is the industry-standard Apache web server that powers literally thousands of web sites around the world. As of OS X 10.5.5, it's Apache version 2.2.9.

So what can you do with OS X's built-in Web server? Almost anything, though the one thing you probably can't do is use it to serve web pages to the outside world, at least not easily. Many ISPs don't allow web servers to run on a standard home account, and even if they do, your firewall and/or router may make it difficult for users to reach your site. If you get around those problems, you'll still need to arrange for a domain name to point to your home machine-and again, your ISP may make that difficult. You can solve some of these issues by using a service such as DynDNS, which lets you assign a domain name to an ever-changing home IP address. You'll still have issues if your ISP won't allow you to host sites, however.

So if you can't serve sites to the outside world, why then might you want to run a web server anyway? Perhaps, like me, your job requires you to maintain a web site, and you'd like to keep a copy of it locally for testing. Or perhaps you'd like to try out some of the popular blogging web applications (WordPress, Movable Type) or some of the hundreds of content management systems available (Geeklog, for instance, which powers macosxhints.com) on your own Mac before you decide to launch a site with a web hosting company. (As an aside, this is exactly how macosxhints.com got started-I installed Geeklog locally and ran it on my own Mac for a couple of months before I launched the site to the public. In many ways, the built-in OS X web server is the one piece of technology most responsible for my launching macosxhints.)

image
Whatever the reason, OS X makes it super easy to run a web server on your very own Mac. You can enable the built-in web server by clicking the Web Sharing button in the Sharing System Preferences panel. Once enabled, you'll see a couple of links in the area to the right of all the sharing options; one lists your computer's web site URL, and the other lists the URL for your personal site. For most users, these addresses will appear as a series of (IP address) numbers-in my case, they're listed as http://192.168.1.44 and http://192.168.1.44/

3 . Serve local web pages via name not IP number

robg, respectively. If I open Safari or any other web browser and enter those URLs, I'll see the standard pages as shown in the image at right-that's the computer page at the top, and my personal page at the bottom.

While this works well enough, wouldn't it be nicer to access your locally-hosted sites via domain name, just like you do on the "real" Internet? With a couple of relatively easy edits in the Terminal, you can do just that. Apache includes support for what they call name-based virtual hosts, and by enabling those, you can name your server and its hosted sites anything you like. Here's what you need to do.

These instructions assume that you'll be installing your sites in your user's Sites folder, and that you'll place each different package you want to use (WordPress, Movable Type, etc.) in its own sub-directory, which is a pretty standard practice. They also assume you're using 10.5; this method will not work in 10.4, as it doesn't use Apache 2. It also assumes that you don't need to access any sites stored in the standard /Library -> WebServer -> Documents folder-I do have a relatively simple fix for that problem near the end of this hint, though.

Name your server

The first thing you need to do is come up with the name you'd like to use for your server-keep it short and simple, and restrict it to one word without any punctuation. The whole idea is to make it easy to type. For this example, I'm assuming the server will be called mysites, which would let you type http://mysites into your browser's URL bar.

Once you've come up with a name for your server, you need to tell OS X to look for that name locally before it tries to find it on the Internet. To do this, we'll make a simple change in the /etc/hosts file. My instructions assume you'll be using a Terminal-based text editor, such as vi or nano, but programs wuch as BBEdit and TextMate that offer a command-line interface could also be used-really, any text editor that lets you edit with root account privileges would do the trick.

Edit the hosts file in Terminal by typing sudo nano /etc/hosts, and then enter your password when prompted. The nano editor will open, displaying something like this:

### Host Database## localhost is used to configure the loopback interface# when the system is booting.  Do not change this entry.##127.0.0.1       test.super127.0.0.1       localhost255.255.255.255 broadcasthost...

Add a row just above the 255.255... line by pressing Return with the cursor at the start of that line, then use the arrow keys to move up, and add this entry:

127.0.0.1       mysites

Replace mysites with whatever name you've chosen for your server, and then save the file and quit the editor (press Control-X to exit, Y to save your changes, and then Return to accept the filename if you're using nano).

Set up Apache

Now that you've named your server, you need to tell Apache how to convert mysites into the IP address of your Mac, so that it can display your web pages. The file you need to modify can be found in /etc/apache2/users, so cd there as a first step: cd /etc/apache2/users. In this folder, you'll find a ".conf" file for each user on your Mac. You want to edit the file for your user, again with root privileges; type sudo nano username.conf (where username is your short username) and enter your password when prompted. Move the cursor to the bottom of the file, and add these lines:

NameVirtualHost *:80<VirtualHost *:80>    DocumentRoot /Users/username/Sites    ServerName mysites</VirtualHost>

Replace username with your user's short username, and change mysites to the server name you used when editing the hosts file. Save the file and quit the editor.

If you also need access to sites in the standard /Library -> WebServer -> Documents folder, you need to edit one additional file. First, move into the right directory with cd /etc/apache2/extra, and then edit the httpd-vhosts.conf file (again, using sudo). Add these lines at the end:

NameVirtualHost *:80<VirtualHost *:80>    DocumentRoot /Library/WebServer/Documents    ServerName localhost</VirtualHost>

Save the file, and you'll be able to access those sites by typing http://localhost in the URL address bar, while using your named server will show pages in your user's Sites folder.

Try it out

Those are the only required edits. To make your changes take effect, however, there are two things you need to do. First, as Leopard caches DNS queries, we need to clear the cache to make it read our hosts file again. In Terminal, enter this command then press Return: dscacheutil -flushcache. The other thing you need to do is restart the Apache web server. You can do this in the Sharing System Preferences panel by toggling the Web Sharing off and back on, or in Terminal, you can use this command: sudo apachectl graceful.

Once Apache restarts, test your new named server by opening your favorite browser and typing your server name in the URL bar: http://mysites. If you haven't replaced the default page in your user's Sites folder yet, that's what you should see when the page loads. Now, as you install various web packages into sub-folders, you can access them as http://mysites/wordpress or http://mysites/geeklog, etc. (If you prefer, you could even name your sub-folders as completely separate sites-just duplicate the above changes to the hosts and .conf files, but with your new server name and path directly to a sub-folder.)

If you have other Macs in your home that you'd like to use to access your served pages, you can do that easily, too. Just edit the hosts file on the other Mac as above, but instead of using 127.0.0.1 as the server address, use the IP address of the Mac running the web server (which you can easily find in the Web Sharing System Preferences panel). Remember to clear the cache after editing the file, and you can then access the host Mac's served pages using the defined server name.

I hope the above is clear and easy to follow-I've tested it on two different Macs here, and it works as described. If you have any troubles getting it working, however, please post a question and I'll do my best to answer it. Remember that this hint is for internally-hosted sites only, and it doesn't do anything about providing access for users outside your local network.


Read article at Macworld.com

4 . Featured Local Company

DOG GUARD OF MICHIGAN

810 923-6289
906 N Oak
FEnton, MI

Regional Articles
- Serve local web pages via name not IP number Adrian MI
- Serve local web pages via name not IP number Allegan MI
- Serve local web pages via name not IP number Allen Park MI
- Serve local web pages via name not IP number Alpena MI
- Serve local web pages via name not IP number Ann Arbor MI
- Serve local web pages via name not IP number Auburn Hills MI
- Serve local web pages via name not IP number Battle Creek MI
- Serve local web pages via name not IP number Bay City MI
- Serve local web pages via name not IP number Belleville MI
- Serve local web pages via name not IP number Benton Harbor MI
- Serve local web pages via name not IP number Berkley MI
- Serve local web pages via name not IP number Big Rapids MI
- Serve local web pages via name not IP number Bloomfield Hills MI
- Serve local web pages via name not IP number Brighton MI
- Serve local web pages via name not IP number Burton MI
- Serve local web pages via name not IP number Cadillac MI
- Serve local web pages via name not IP number Canton MI
- Serve local web pages via name not IP number Cheboygan MI
- Serve local web pages via name not IP number Clarkston MI
- Serve local web pages via name not IP number Clinton Township MI
- Serve local web pages via name not IP number Clio MI
- Serve local web pages via name not IP number Coldwater MI
- Serve local web pages via name not IP number Commerce Township MI
- Serve local web pages via name not IP number Comstock Park MI
- Serve local web pages via name not IP number Davison MI
- Serve local web pages via name not IP number Dearborn Heights MI
- Serve local web pages via name not IP number Dearborn MI
- Serve local web pages via name not IP number Detroit MI
- Serve local web pages via name not IP number Dowagiac MI
- Serve local web pages via name not IP number East Lansing MI
- Serve local web pages via name not IP number Eastpointe MI
- Serve local web pages via name not IP number Eaton Rapids MI
- Serve local web pages via name not IP number Escanaba MI
- Serve local web pages via name not IP number Farmington MI
- Serve local web pages via name not IP number Fenton MI
- Serve local web pages via name not IP number Ferndale MI
- Serve local web pages via name not IP number Flat Rock MI
- Serve local web pages via name not IP number Flint MI
- Serve local web pages via name not IP number Flushing MI
- Serve local web pages via name not IP number Fort Gratiot MI
- Serve local web pages via name not IP number Fraser MI
- Serve local web pages via name not IP number Garden City MI
- Serve local web pages via name not IP number Gaylord MI
- Serve local web pages via name not IP number Gladwin MI
- Serve local web pages via name not IP number Grand Blanc MI
- Serve local web pages via name not IP number Grand Haven MI
- Serve local web pages via name not IP number Grand Ledge MI
- Serve local web pages via name not IP number Grand Rapids MI
- Serve local web pages via name not IP number Grandville MI
- Serve local web pages via name not IP number Grosse Pointe MI
- Serve local web pages via name not IP number Hamtramck MI
- Serve local web pages via name not IP number Harper Woods MI
- Serve local web pages via name not IP number Harrison Township MI
- Serve local web pages via name not IP number Hazel Park MI
- Serve local web pages via name not IP number Highland Park MI
- Serve local web pages via name not IP number Hillsdale MI
- Serve local web pages via name not IP number Holland MI
- Serve local web pages via name not IP number Holly MI
- Serve local web pages via name not IP number Holt MI
- Serve local web pages via name not IP number Howell MI
- Serve local web pages via name not IP number Hudsonville MI
- Serve local web pages via name not IP number Inkster MI
- Serve local web pages via name not IP number Ionia MI
- Serve local web pages via name not IP number Jackson MI
- Serve local web pages via name not IP number Jenison MI
- Serve local web pages via name not IP number Kalamazoo MI
- Serve local web pages via name not IP number Lake Orion MI
- Serve local web pages via name not IP number Lansing MI
- Serve local web pages via name not IP number Lapeer MI
- Serve local web pages via name not IP number Lincoln Park MI
- Serve local web pages via name not IP number Livonia MI
- Serve local web pages via name not IP number Ludington MI
- Serve local web pages via name not IP number Macomb MI
- Serve local web pages via name not IP number Marquette MI
- Serve local web pages via name not IP number Midland MI
- Serve local web pages via name not IP number Monroe MI
- Serve local web pages via name not IP number Mount Clemens MI
- Serve local web pages via name not IP number Mount Morris MI
- Serve local web pages via name not IP number Mount Pleasant MI
- Serve local web pages via name not IP number Muskegon MI
- Serve local web pages via name not IP number New Baltimore MI
- Serve local web pages via name not IP number Niles MI
- Serve local web pages via name not IP number Northville MI
- Serve local web pages via name not IP number Novi MI
- Serve local web pages via name not IP number Oak Park MI
- Serve local web pages via name not IP number Okemos MI
- Serve local web pages via name not IP number Owosso MI
- Serve local web pages via name not IP number Petoskey MI
- Serve local web pages via name not IP number Pinckney MI
- Serve local web pages via name not IP number Plymouth MI
- Serve local web pages via name not IP number Pontiac MI
- Serve local web pages via name not IP number Port Huron MI
- Serve local web pages via name not IP number Portage MI
- Serve local web pages via name not IP number Redford MI
- Serve local web pages via name not IP number Rochester MI
- Serve local web pages via name not IP number Rockford MI
- Serve local web pages via name not IP number Romulus MI
- Serve local web pages via name not IP number Roseville MI
- Serve local web pages via name not IP number Royal Oak MI
- Serve local web pages via name not IP number Saginaw MI
- Serve local web pages via name not IP number Saint Clair Shores MI
- Serve local web pages via name not IP number Saint Johns MI
- Serve local web pages via name not IP number Saline MI
- Serve local web pages via name not IP number Sault Sainte Marie MI
- Serve local web pages via name not IP number South Haven MI
- Serve local web pages via name not IP number South Lyon MI
- Serve local web pages via name not IP number Southfield MI
- Serve local web pages via name not IP number Southgate MI
- Serve local web pages via name not IP number Sterling Heights MI
- Serve local web pages via name not IP number Sturgis MI
- Serve local web pages via name not IP number Swartz Creek MI
- Serve local web pages via name not IP number Taylor MI
- Serve local web pages via name not IP number Temperance MI
- Serve local web pages via name not IP number Three Rivers MI
- Serve local web pages via name not IP number Traverse City MI
- Serve local web pages via name not IP number Trenton MI
- Serve local web pages via name not IP number Troy MI
- Serve local web pages via name not IP number Utica MI
- Serve local web pages via name not IP number Walled Lake MI
- Serve local web pages via name not IP number Warren MI
- Serve local web pages via name not IP number Waterford MI
- Serve local web pages via name not IP number West Bloomfield MI
- Serve local web pages via name not IP number Westland MI
- Serve local web pages via name not IP number White Lake MI
- Serve local web pages via name not IP number Wixom MI
- Serve local web pages via name not IP number Wyandotte MI
- Serve local web pages via name not IP number Wyoming MI
- Serve local web pages via name not IP number Ypsilanti MI
- Serve local web pages via name not IP number Zeeland MI
Related Local Event
Real-Time & Embedded Computing Conference-Detroit (RTECC)
Dates: 9/17/2009 - 9/17/2009
Location: Sterling Inn Banquet & Conference Center
Sterling Heights, MI
View Details

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Advertising Family Home Services Real Estate Resources
Business Services Fashion Industrial Goods & Services Retail & Consumer Services
Career Financial Services Insurance Software
Cars Food & Beverage Internet Technology
Computer Hardware Franchise Legal Telecommunications
Construction Health Miscellaneous Trade Shows
Education Holidays Nightlife Travel
Entertainment Home Appliances Online Database Weddings
Environmental Home Electronics Pets World History