[HOWTO] - Modify the personal web sharing

solrac

Mac Ninja
here i posted this on macosxhints.com but i don't know when or where it'll show up
---------

Personal Web sharing on Mac OS X is cool. You get a home page on the internet right from your user's folder (in the sites folder)!

However, what if you have an external hard drive with a folder of MP3s created by iTunes that's 5 GB, and you want to list all the folders and files in there instantly? And you don't want to copy the songs to your Sites folder. You want to leave them on the hard drive.

Well the first step was to put an alias to the MP3 folder in your Sites folder. However that doesn't work.

Luckily, I know a little bit about Apache and UNIX, and apple has provided a link to the Apache manual.

Basically, the apache web server is the software that makes your web page available. When you activate web sharing, it's a running program, just like Internet Explorer is a running program. Of course mac os X won't ever show it.

The program is not called Apache. It's called httpd. If you go to terminal and type ps -aux, it will list all your processes. If web sharing is on, you'll notice httpd in there.

All the settings for Apache are controlled by text files, called configuration files. These are stored at /private/etc/httpd

(Note, you can not edit the configuration files unless you are root user.)

First I tried editing the config files under /private/etc/httpd/users, which are the configurations for the web sites for actual users on your computer. But nothing I did there worked! So I edited the MAIN apache config file. It is here:

/private/etc/httpd/httpd.conf

In the finder, select Go... Go To Folder. Type in /private/etc/httpd

The window will pop up. Also, have Text Edit Open. It should be in your dock. Drag httpd.conf to Text Edit (in the dock). It will open up.

This file is nicely commented with many instructions. You are looking for this text, about 1/3 of the way down the file...

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/Library/WebServer/Documents

Anything preceded by a # is ignored. You just want to change DocumentRoot to /Volumes/[your hard drive name]/[your mp3 folder name]

a couple paragraphs down you must do it again. The text says

#
# This should be changed to whatever you set DocumentRoot to.
#

then the directory, make it the same:
<Directory "/Volumes/[your hard drive]/[your mp3 folder]

Now save the file. Make a backup if you'd like first. You cannot save changes unless you're logged in as root.

Now, when you view your web page, you'll see a list of your mp3s and folders instead of the default hello page!

If anyone knows why changing the the users config files don't work for me let me know!!

Also, if you screw up the config files, you can run the command:

apachectl configtest

You'll get an output showing you what's wrong.
 
Hey, did you notice that iTunes 3 has XML export, so you can export a song-list to XML. There is apparently a default style-sheet, though you could tweak it with your own formatting. Getting it to link to the files wouldn't be too hard I expect.


:cool:
 
OH AWESOME.

And Flash can read XML, and also read ID3 tags! I could make a flash app to read your iTunes lists!!
 
Back
Top