WebSharingOrientation

=Web Sharing Orientation=

Some tips and tricks to using the Apache web server that ships with Mac OS X.

Starting and Stopping Web Sharing

 * In your System Preferences, go into Sharing and turn on Web Sharing
 * You should now be able to see an Apache web server running at http://localhost/
 * Restart Web Sharing any time you make changes to /etc/apache/httpd.conf. See examples below.

Troubleshooting

 * Problem with permissions with Leopard-upgraded account.
 * Terminal: sudo cp /etc/httpd/users/*.conf /etc/apache2/users/.

Serving Up Documents

 * 1) System Root
 * 2) * Browser: http://localhost/
 * 3) * Terminal: cd /Library/WebServer/Documents
 * 4) User-Specific
 * 5) * Browser: http://localhost/~firstlast/
 * 6) * Terminal: cd ~/Sites

Enabling PHP Support
You want to explore some PHP-dependent applications like MediaWiki or Movable Type and need to enable PHP support.


 * 1) Terminal:  sudo vi /etc/apache2/httpd.conf
 * 2) * Uncomment: LoadModule php5_module       libexec/apache2/libphp5.so
 * 3) ** vi (find the php5 string): /php5
 * 4) ** vi (move to the start of the line): ^
 * 5) ** vi (erase the # character): x
 * 6) ** vi (colon character, write and quit): :wq
 * 7) GUI Editor Alternative:  sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/apache2/httpd.conf
 * 8) * Erase the # in front of the LoadModule php5_module       libexec/apache2/libphp5.so line.
 * 9) * Save and exit. Make sure it does not Line-Wrap.


 * Restart Web Sharing so Apache re-reads the new configuration information.

Aliasing Directories
You want http://localhost/~janebuck/MacOSXHacks/ to show up as http://localhost/MacOSXHacks/. Aliasing is the way to do this.


 * 1) Determine the full path to the directory you want to alias
 * 2) * Terminal: cd ~/Sites/MacOSXHacks/
 * 3) * Terminal: pwd
 * 4) ** Result: /Users/janebuck/Sites/MacOSXHacks
 * 5) Add Alias:  Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks
 * 6) Terminal:  sudo vi /etc/apache2/httpd.conf
 * 7) * vi (find the IfModule alias_module string): /IfModule alias_module
 * 8) ** Moves to Line: &lt;IfModule alias_module&gt;
 * 9) * vi (insert after current line): o
 * 10) * vi (type in alias text):
 * 11) **Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks
 * 12) * vi (exit edit mode with Esc key): &lt;Esc&gt;
 * 13) * vi (colon character, write and quit): :wq
 * 14) GUI Editor Alternative:  sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/apache2/httpd.conf
 * 15) * Locate: &lt;IfModule alias_module&gt;
 * 16) * Add Alias: Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks
 * 17) * Save and exit. Make sure it does not Line-Wrap.


 * Restart Web Sharing so Apache re-reads the new configuration information.

Enabling User CGI Support
You want http://localhost/~janbuck/cgi-bin/musicpad.cgi to do more than just serve up the text of a Perl script.

&lt;Directory /Users/janebuck/Sites/cgi-bin&gt; Options Indexes FollowSymlinks MultiViews ExecCGI AllowOverride None Order allow,deny Allow from all &lt;/Directory&gt;
 * 1) Determine the full path to the directory you want to have Executable content
 * 2) * Terminal: cd ~/Sites/cgi-bin/
 * 3) * Terminal: pwd
 * 4) ** Result: /Users/janebuck/Sites/cgi-bin
 * 5) Edit /etc/apache2/httpd.conf
 * 6) Uncomment:  AddHandler cgi-script .cgi
 * 7) Configure /Users/janebuck/Sites/cgi-bin to be Executable:


 * Restart Web Sharing so Apache re-reads the new configuration information.

=References=


 * System Preferences Help (?)
 * musicpad.cgi