home folder

Handle Your Home Folder

By: Jon Gales

This is the first of a weekly series on being a power user. Since every
week you’ll see a new article on Monday, it’s smartly called “Power User
Monday”. If you have any tips, questions or comments please shoot them
my way.

Upon switching to OS X, most 9 afficianodos wanted to make X behave like 9.
That’s when the little hacks to get the trash can to be on the desktop, Apple

menu’s to come back, and the like all came into power. These things were really
popular because no one really knew how to use OS X. Times have changed. To
be a power user in OS X you gotta maximize what’s given. Here’s how to get
the best out of the Home Folder:

  1. Don’t store any personal data outside your Home folder. There’s only one
    exception… If you have a seperate hard drive or partition that certain
    types of file (media?) stay on. In this case just make sure you remember
    to back up that drive as well. If everything is in your home folder, Backup
    (from .Mac) or any other backup tool makes it easy to have all your data.
    A nice thing about X is that it even stores your prefs in the home folder
    (Library).

  2. Don’t have folders on your Desktop, have aliases that link to folders in
    your Home Folder. Folders on the Desktop are a waste of time. It may sound
    odd at first, but the advantage is obvious on a second look. Desktop’s get
    cluttered (just like your real desk
    can get stacked up and become confusing). I keep an alias of my Documents
    Folder on my Desktop, as well as another alias for whatever I’m
    working
    on (PowerUser Monday for instance). If you still aren’t convinced… When
    you backup your Documents Folder, all of your docs go with it. Otherwise,
    you’d have to look through tons of folders and sub-folders to get the same
    backup. Any organization you can add to your computing will speed up your
    work time, which is great unless
    you get paid by the hour icon smile Handle Your Home Folder .

  3. Put the Home Folder (and any common sub-folders) you use into the Dock.
    That way with one click you can access anything on your Home folder from
    any
    application. Update: Had some people asking how this helps… Click and hold, control click, or (if you have a 2 button mouse) right click on the icon in the Dock and see the folder displayed as a menu. I can’t tell you how much this speeds up things, and I see very
    few people doing it. I have the Home Folder, Documents and Desktop folders
    in my dock (as well as the Applications Folder).

The Home folder is the hub of data for OS X. Make it your friend. Check back
next Monday!

Web Serving Made Easy Part 1

In the next month (or two) I’ll cover the scope of web serving on MacOS X
Jaguar. You don’t need the server edition, and you don’t need to buy anything
else. Today is going to be the basics, next week we’ll learn how to do port
forwarding and get a domain name.

The first part of web serving is turning Apache on. Apache is the world’s
most popular web server, and it happens to come built into OS X! To turn it
on just head over to System Preferences and choose Sharing. Click the checkbox
next to "Personal Web Sharing". That’s it…. You’ve just started up your own
web server.

Fire up your web browser and type ‘localhost’ into the link bar. This is a
de facto address for your compute, so in other words your browser is going
to be asking a web server on your computer for its index. You should be greeted
with a simple page that comes with Jaguar. If not, make sure you’ve turned
on "Personal Web Sharing".

In your home folder there is a folder called "Sites". Anything you
place in this folder can be accessed via the web by messing with the url: localhost/~username will fetch
the files located in the site folder of the user dubbed "username". Try it
out with your username. You should see another simple web page that’s built
into the system.

Here’s where it gets interesting. If you are not behind a router, and have
broadband you’ll be able to share files or set up a web site for all to see.
If you are behind a router, you’ll have to wait until next week. If you don’t
know if you’re behind a router, just continue and see what happens… It can’t
hurt.

Your friend can’t use localhost because
that will make his browser look on his computer. You have to tell it to look
on yours. Look up your IP address by going to System Preferences and choosing
Network. Highlight and copy the IP address and then make it into a link like
this:

http://youripadress

If a friend can type that into her browser and get the same page you saw,
then you’ve successfully completed part one. Stay tuned in the coming weeks,
I’ll be showing how to do everything from IP forwarding to installing MySQL.

Web Serving Made Easy Part 3

By: Jon Gales

Last week we learned the finer points of IP forwarding. Hopefully you’ve gotten
that under control. This week we’ll learn how to do some fun stuff with PHP
and CGI. Next week will be the last lesson before the first application (setting
up a weblog).

PHP is the world’s most popular web scripting language. It’s GREAT. It’s also
installed on your computer already, you just have to activate it. Here’s how:

  1. Open a terminal window
  2. type “cd /etc/httpd
  3. type “sudo apxs -e -a -n php4 libexec/httpd/libphp4.so
  4. On OS X
    prior to 10.2, type
    sudo perl -p -i.bak -e 's%#(AddType S+-php[ -])%$1%i' httpd.conf
  5. On OS X 10.2,
    type
    echo ‘echo "AddType application/x-httpd-php .php" >> /etc/httpd/httpd.conf'
    | sudo sh -s
  6. No matter what OS type “sudo apachectl graceful”
[via Entropy.ch]

Now fire up your plain text editor of choice (BBedit or TextEdit set to plaintext
mode or anything else that writes plain text) and drop the following code into
it:

phpinfo();

?>

Name the file info.php and place it in your sites folder (it’s right off your
home folder). Open up http://localhost/~YOUR_USER_NAME/info.php
in your browser of choice. This simple script will (hopefully) access the phpinfo() function
which will output the specifics of your install to your browser. If PHP has
been successfully activated, you’ll
see a nice long page full of info you probably won’t care about. If it doesn’t
work, you’ll most likely see the text of the script. Go back and try again.
Make sure you did the right commands for the right version of OS X.

Once you’ve got PHP up and running, try your hand at CGI (it’s already active
so it’s quite easy). Point your browser to http://localhost/cgi-bin/test-cgi and you’ll note that there is an error. It’s not the common 404 not found error,
it’s the Forbidden error. From a web developer point of view, this is a much
worse error. In this case it’s not hard to solve.

The set up that OS X ships with puts CGI scripts in the directory: /Library/WebServer/CGI-Executables/ which
is curious because to access the scripts you go to /cgi-bin/script name.
Most people would thing that there would be a directory called cgi-bin inside
/Library/WebServer/Documents. Get over it. If you need the techie
explanation head over to O’Reilly’s
Mac Dev Cente
r. For the rest of you, just remember
CGI goes in /Library/WebServer/CGI-Executables/.

Now, let’s get that script working. Fire up the Terminal if it’s closed and
type:

sudo chmod 755 /Library/WebServer/CGI-Executables/test-cgi

This runs the chmod program as super user. You’ll be prompted for a password,
just give it the administrator password. The 755 changes the permissions for
the file test-cgi to a level that can be executed
by Apache.
CGI scripts
are actually programs, and for programs to be run the user has to have the
correct permissions. Now, go back to http://localhost/cgi-bin/test-cgi and
note the output. You’ve now just run your first CGI script!

These two skills will be very important in the near future, even if you aren’t
a programmer. There are thousands of free programs that can be run with these
techniques which can speed things along when you’re making a site. Two weeks
from now we’ll meet a few of the more well known ones.