Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Serve web pages via Apache from a USB key drive Internet
For web developers, Mac's Apache web server won't automatically serve web-related files that reside on a USB key drive. Any effort to do so results in an Apache error page. Read the rest of the hint for details on how to make Apache happily serve up pages from a USB key drive.

By default, the USB key drive is usually named something like "NO NAME," so change it to something more convenient - short, no spaces, and note that the name must be uppercase. As an example, let's name the key drive BOB. The actual unix location of key drive BOB is /Volumes. Apache won't serve anything from there, so you need to go into your Sites directory and create a unix-style symbolic link to BOB. Do not create a Mac alias, because it's not the same thing. In Terminal.app, enter the following commands (don't type the % - it represents your unix prompt):
% cd Sites
% ln -s /Volumes/BOB BOB
Next you have to edit your Apache user config file, located in /etc/httpd/users. For now, let's say your shortname is xyz. The default xyz.conf file in that directory looks something like this:
<Directory "/Users/xyz/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
So, still in Terminal.app, type the following commands (don't type the ## or anything after them; that's just a comment to explain what's happening with each command):
% cd /etc/httpd/users                ## Change into the directory
% sudo cp xyz.conf xyz.conf.original ## Make a backup of your config file
% sudo vim xyz.conf                  ## Use vim (or your editor of choice)
Edit your config file to look like this, (replace xyz with your short username):
<Directory "/Users/xyz/Sites/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
<Directory "/Users/xyz/Sites/BOB">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
After saving and closing your config file, restart Apache by typing sudo apachectl graceful. Now you can access the key drive in a browser at this URL (replace xyz with your short username, of course): http://127.0.0.1/~xyz/BOB/ If you have PHP enabled and running, you can test PHP locally as well. Hooray!
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[9,641 views]  

Serve web pages via Apache from a USB key drive | 1 comments | Create New Account
Click here to return to the 'Serve web pages via Apache from a USB key drive' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Serve web pages via Apache from a USB key drive
Authored by: punkish on May 27, '04 02:09:09PM

Nice, detailed hint. My comment has to do with just the following statement...

<blockquote>
The actual unix location of key drive BOB is /Volumes. Apache won't serve anything from there, so you need to go into your Sites directory and create a unix-style symbolic link to BOB.
</blockquote>

While the above may be true specifically for USB key drives, it is NOT true for drives mounted under /Volumes. I have an external firewire drive that is attached to my iBook. My entire website is on the external drive, and Apache serves it happily. The really cool thing about this setup is that if my iBook is down or away, I just grab the drive and stick it in a different computer. The path remains the same, and Apache on the new computer serves everything exactly the same (provided, of course, its conf is the same as the one on my iBook).



[ Reply to This | # ]