Read Mac Hacks Online

Authors: Chris Seibold

Tags: #COMPUTERS / Operating Systems / Macintosh

Mac Hacks (12 page)

Hack 15
. Host a Web Page on Your Mac (and Get at Your Files Anytime)

The
biggest trick to hosting a web page on your Mac isn’t the
software or the content—it’s being able to tell people how to
get
to the webpage. Take away that hassle with this
supremely useful hack.

Twitter, Facebook, and other social media sites are great, but
sometimes you want to go over their character limit or burst out of their
confines. There are situations where you want to be the boss, where you
want total control. On those days, you want to publish your own web page!
For times like those, you need a static IP address.

Imagine, for example, you have a friend with a quirky sense of
humor. Further, imagine you draw a weird cartoon on a nightly basis that
you want to share with him. You
could
clog up your
Twitter feed by posting a link to the imgur location of the ’toon, but
some of your other followers might not appreciate your masterpiece. Or you
could simply email it to him, but that seems like a lot of effort for one
guy. Why not just have him check a page you host on your Mac? He’ll get
cracked up and no one will be the wiser.

Let’s get started.

Do You Have the Bandwidth?

First,
check you Internet connection. This hack relies on your
Mac sending information out and, for most home Internet connections, the
upstream bandwidth is a lot less than the downstream bandwidth. Which
means that, while your Mac might not have any trouble streaming three
online HD movies at once, uploading a web page might be a little too
much for your Mac to handle. Head
to
Speakeasy
to test your
upload speed (
Figure 3-4
).

Figure 3-4. Expect a large inequality between upload and download speed.
Why the difference? Consumers don’t often judge ISPs by their upload
speeds.

In this test case, the upload speed was 1.95 Mbps. The question
now becomes, is that enough to satisfy the uploading needs of this hack?
It is if you make a small web page and have a moderate number of
visitors. In this example, the extremely simple web page (covered later
in this hack) clocks in at 43 Kb. So in the best-case scenario, the host
Mac could conceivably serve 46 (1.95 Mbps/43 Kb ≈ 46) pages per second.
(Actually, that estimate is too high because it leaves no bandwidth left
over for browsing, but it also tells us that serving up the occasional
page shouldn’t be a
problem.)

Warning: Check with your ISP to make sure hosting a web page
from your Mac is allowed under their terms of service. They’d probably
never notice if you kept everything small-time, but better safe than
sorry, right?

Make a Web Page

You
can only host a web page on your Mac if you have
something to host. So let’s make something! In this hack, we’ll use
KompoZer
, a good, free
WYSIWYG HTML editor, but feel free to use whatever you’re comfortable
with.

Here’s the code for our super-simple web page (shown in
Figure 3-5
):



content=
"text/html; charset=ISO-8859-1"
http-equiv=
"content-type"
>
Read Mac Hacks (12 page) Page 12 Read Book Online,Top Vampire Books Read Online Free


Toon of the day:


style=
"width: 278px; height: 370px;"
alt=
"Vol's Christmas Present"
src=
"file:///Users/cks/Desktop/Untitled-3.gif"
>



Figure 3-5. The code for this basic web page in KompoZer.

When
you’re serving web pages from your Mac at least one of
them has to be called
index.html
.
Since this example only uses one page, guess what that page is going to
be named? (See
Figure 3-6
for the
answer.)

Figure 3-6. Saving the web page with the proper name
(
index.html
) and in the proper location (your
Sites folder). These are choices that matter, so be careful!

You’re almost done, all you have to do now is tell your Mac to
share your web page. In older versions of OS X (Lion and earlier) you
can simply head to System Preferences→Sharing and then check the box
next to Web Sharing; your Mac will then tell you where users on your
local network can reach your site. In Mountain Lion, things are
trickier. How tricky, you ask? Tricky enough to get their own hack! See
[Hack #9]
for details.

Once you enable personal web sharing, you’re done. Anyone on your
local network can navigate to your computer and see the site you made.
This is useful for an office or home network, but we want more from this
hack—we want folks across town or across the country to see the
web
page!

Fake a Static IP

The
reason that outsiders can’t see your web page is because
there isn’t any way to tell them how to get to it. In the wider world,
this isn’t a problem because of
domain name servers
and
static IP addresses
. Domain name servers
translate the name of a website into the proper IP address. For example,
when you type www.google.com into your browser, a domain name server
changes that address into computer-friendly numbers that match up with
the range of IP addresses that Google has reserved. Unfortunately, you
probably don’t have a static IP (but if you do, you’re finished with
this hack!).

As
you probably know,
IP
stands for
Internet Protocol. An IP address identifies where your computer can be
found over the Internet. Most ISPs (Internet Service Providers) use
dynamic
IPs, meaning that your computer’s address
can change from time to time. This setup is fine when you’re using your
computer to browse the Web, but not very useful when you (or others)
want to find your particular machine somewhere on the Internet.

You can, of course, get a static IP address for your favorite Mac.
Some ISPs will give you a static IP if you just ask, but more often the
ISPs see static IPs as things of value and want to charge a fee for
giving you one. The fees vary widely (I found rates anywhere from $5 to
$35 a month) and if you use a laptop in multiple locations, a single
static IP address will only work at one location.

What’s required is a method to approximate the functionality of a
static IP address without actually
having
a static
IP address. One solution would be to give your computer a name, store
said name in a centralized location, and then have your computer relay
its current IP address to the centralized location. That way, when you
or someone else went looking for your computer, they could look for its
name (rather than its IP address) and then be forwarded the current IP
address of your machine. As
luck would have it, that’s exactly the way No-IP
works—and the best part is that it’s a completely free service.

The
first step is, predictably, a quick trip to
No-IP
. Download the client for OS X.
While you’re at the site, sign up for an account, too—you won’t be
getting very far in this hack without one. The signup process is pretty
standard and it’s a small price to pay for the increased functionality
coming your way.

Next, install No-IP. The installation process is standard except
that the No-IP installer installs a
daemon
(a
program that automatically starts and runs in the background). The
daemon—which is required if you wish to run No-IP as a background
process—is not activated just by installing (you have to turn it on
manually), so don’t worry that installing No-IP is adding another
background process; it won’t run in the background until you instruct
the No-IP client to do so.

Check your email and, in the email No-IP sent you, click the
activation link. Then, head to your Applications folder and fire up
No-IP DUC. After you authenticate, you’ll see the external IP address of
your Mac (
Figure 3-7
).
This is the number the outside world can use to find you.

Figure 3-7. No-IP has discovered your external address! You’ve completed
the first step toward getting your web page to the rest of the
world.

That’s great, but it doesn’t really help you too much unless you
want to send that IP address out to all your friends whenever it
changes. That’s too much work. You want No-IP to do its thing
automatically; for that to happen, you need to enable the daemon.

To start the daemon, we need to take care of a few things. First
No-IP needs to know who you are. In No-IP, choose No-IP DUC→Preferences.
You may be asked to enter your email address and password; if so, enter
them. If not, in the Preferences dialog box, click the Change button
next to Email/Username and then log in with your username and password.
Then click the Settings tab and check the box next to “Automatically
Start at Login.” Finally, go to the Daemon tab and click the box next to
“Launch Daemon at System Startup” (
Figure 3-8
). You’ll be asked
for your user password. The process is safe, so go ahead and enter your
magic string of authorization.

Figure 3-8. The last step of setting up No-IP DUC to run in the background
and automatically! People can reach this Mac’s website at
machacks.no-ip.org
. Go ahead
and try it!

At this point, all the hard work is done: you’ve created a web
page, gotten a dynamic IP address updater, and have a name for your web
page. If your Mac is plugged directly into the Internet, you’re all set.
If you go through a router, you have some work left to do. You need to
open port 80; exactly how to do that varies depending on your router.
Chances are you can visit your router’s configuration page and get it
done with a minimal amount of effort.

Oh, you want to actually
share
the web page
you made? Just tell people to go to www.thenameyouchoseearlier.org.
They’ll see your page just like you’re some big-time
corporation!

Other books

Zombies by Joseph McCullough
City of Death by Laurence Yep
Blueberry Muffin Murder by Fluke, Joanne
United as One by Pittacus Lore
Engaging Evelyn by Salaiz, Jennifer
Drowned Ammet by Diana Wynne Jones
Treason by Orson Scott Card
Ex Delicto by Valentina Khorkina


readsbookonline.com Copyright 2016 - 2024