Sharing Remotely: Personal Web Sharing

Sharing Remotely: Personal Web Sharing

User Level:






The final way that OS X shares files is via the Web. OS X provides a complete install of the industrial-strength Apache web server (—the same one used by many of the biggest websites on the Internet. While it may sound a bit strange to include a web server as a way to "share" files, that's exactly what you're doing: allowing other users to access files on your computer. And since Apple includes Personal Web Sharing in the Sharing pane of System Preferences, I'm going to treat it like a sharing service.

What Does It Share?

Personal Web Sharing actually shares at both the user level and at the computer level. More specifically, it can share the contents of each user's /User/username/Sites folder, as well as the contents of /Library/WebServer/Documents. I say can share because OS X is configured, like most web servers, to not show the contents of directories; rather, you can only access a file if you have its complete file name or if it's linked from another web page that you can view. By default, unless someone accessing a website on your Mac knows the URL of a specific file, all they'll be able to see is the file index.html or home.html—which is the default page for any website—at the root level of your Sites or Web Server Documents folders.


Since Personal Web Sharing is intended to be a way to share a website over the Internet, each user's Sites folder and the main web server Documents folder have basic websites pre-installed. You can view these default websites in your browser if you enter http://localhost/ (for the main Documents folder) or http://localhost/~username (for any user on your Mac) (Figure 10.8). (localhost tells your browser to access the local web server.) If you replace these default website files with your own website, people around the world can view that site by pointing their web browser to your Mac.

Click To expand Figure 10.8: A default user website in OS X

However, even though the main purpose of Personal Web Sharing is to share websites, you can also use it as a way of sharing other files, as well. Any file that you place in your personal Sites folder will be available to anyone who has the full address of that file. For example, if you put a document called report.doc in your Sites folder, you can tell your coworker to enter http://yourIPaddress/~yourusername/report.doc in their web browser and it will be downloaded to their computer. At the same time, no one else will know that file even exists. The disadvantage (or advantage, depending on how you look at it) of Personal Web Sharing is that unless you're a web server guru who knows how to trick out your Apache installation, users can only download files from you; they can't upload files. However, Personal Web Sharing can be a very quick and convenient way to provide someone with access to a file without having to give them a user account or configure any other services.


Unless you've purchased your own Internet domain and have it assigned to your personal Mac, I recommend using your personal Sites folder for sharing files and websites. The /Library/Web Server/Documents folder can be used, but it is generally intended for computers that are used as dedicated web servers, and placing files there requires admin access.

Who Can Access Files?

Although it's possible to configure Apache to require usernames and passwords to access files, by default Personal Web Sharing does not limit access to particular users or require any passwords. Thus anyone with a web browser can access the files in your Sites folder or the main Web Server Documents directory. However, as I mentioned above, unless you purposely link to files (by editing the index.html file, or creating your own, and including URL links to other files and web pages in it), only those users who know the exact links to specific files will be able to access them.

How Do I Configure It?

To enable Personal Web Sharing, you just need to check the box next to Personal Web Sharing in Sharing preferences. Apache will start up, and you've got a web server every bit as powerful as many of the major sites on the Internet.

Other Configuration Options

Because Personal File Sharing is actually a complete installation of the Apache web server, it's incredibly configurable and extendable. It's possible to configure Apache so that specific files and folders inside the various web document folders require usernames and passwords. You can install PHP or use CGI scripts. Pretty much anything that can be done with a web server can actually be done on your Mac. Unfortunately, I don't have the space to show you all the cool things you can do with Apache, but I encourage you to browse the full Apache manual installed on your computer; you can access it by pointing your web browser to http://localhost/manual/.


Most of the tweaks and changes you make to Apache are done within the file /etc/ httpd/httpd.conf. Sometimes Mac OS X system updates install a new version of this file that provides additional or different Apache functionality. Unfortunately, this means you lose all of your customizations. Apple's installer will often back up the existing file (the 10.2.4 update renamed the existing file as httpd.conf.applesaved), but to be safe you should be sure to back up this file before installing any system updates (assuming you aren't backing it up as part of your normal backup strategy). If a system update removes your edited version, you can use the backup copy to add your customizations to Apple's newly installed version. (In fact, it's a good idea to always make backups of any .conf file that you manually edit, just in case something like this happens.)

How Do Others Access Files?

If you're simply using Personal Web Sharing to share individual files with remote users, you'll need to give them the precise URL of each file: http://yourIPaddress/~yourusername/filename. If you've created sub-folders inside of your Sites folder, the address to files inside those folders would be http://yourIPaddress/~yourusername/foldername/filename. By entering the URL to a file in their web browser, the file will be downloaded to their computer.

If you're actually using Personal Web Sharing as a web server, you should give other people the URL of http://yourIPaddress/~yourusername/to allow them to view your website (assuming you've followed the standard of using index.html or home.html as your website's home page). You could also give them the specific address of any other web page in your Sites directory.


If you're new to HTML and web pages, check out the default index.html web page inside your personal Sites folder (type http://yourIPaddress/~yourusername/ in your web browser). It gives you a quick primer on using your Sites folder for a website.