WebSharingOrientation

From Clothbot

(Difference between revisions)
Jump to: navigation, search
Revision as of 04:17, 4 January 2008 (edit)
AndrewPlumb (Talk | contribs)
(Aliasing Directories)
← Previous diff
Current revision (04:34, 4 January 2008) (edit)
AndrewPlumb (Talk | contribs)
(Enabling User CGI Support)
 
Line 1: Line 1:
=Web Sharing Orientation= =Web Sharing Orientation=
 +
 +Some tips and tricks to using the Apache web server that ships with Mac OS X.
==Starting and Stopping Web Sharing== ==Starting and Stopping Web Sharing==
Line 5: Line 7:
* In your '''System Preferences''', go into '''Sharing''' and turn on '''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/'' ** 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=== ===Troubleshooting===
Line 19: Line 22:
#* Browser: '''http://localhost/~firstlast/''' #* Browser: '''http://localhost/~firstlast/'''
#* Terminal: '''cd ~/Sites''' #* 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.
 +
 +# Terminal: '''sudo vi /etc/apache2/httpd.conf'''
 +#* Uncomment: ''LoadModule php5_module libexec/apache2/libphp5.so''
 +#** vi (find the ''php5'' string): '''/php5'''
 +#** vi (move to the start of the line): '''^'''
 +#** vi (erase the ''#'' character): '''x'''
 +#** vi (colon character, '''w'''rite and '''q'''uit): ''':wq'''
 +# GUI Editor Alternative: '''sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/apache2/httpd.conf'''
 +#* Erase the '''#''' in front of the ''LoadModule php5_module libexec/apache2/libphp5.so'' line.
 +#* Save and exit. Make sure it '''does not''' Line-Wrap.
 +
 +* Restart '''Web Sharing''' so Apache re-reads the new configuration information.
==Aliasing Directories== ==Aliasing Directories==
Line 30: Line 49:
# Add Alias: ''Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks'' # Add Alias: ''Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks''
## Terminal: '''sudo vi /etc/apache2/httpd.conf''' ## Terminal: '''sudo vi /etc/apache2/httpd.conf'''
-##* vi (find the ''IfModule alias_module'' string): '''/IfModule alias_module'''+##* vi (find the ''IfModule alias_module'' string): '''/IfModule alias_module'''
-##** Line: ''<IfModule alias_module>''+##** Moves to Line: ''<IfModule alias_module>''
##* vi (insert after current line): '''o''' ##* vi (insert after current line): '''o'''
-##* vi (type in alias text: ''Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks''+##* vi (type in alias text):
 +##**''Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks''
##* vi (exit edit mode with ''Esc'' key): ''<Esc>'' ##* vi (exit edit mode with ''Esc'' key): ''<Esc>''
##* vi (colon character, '''w'''rite and '''q'''uit): ''':wq''' ##* vi (colon character, '''w'''rite and '''q'''uit): ''':wq'''
Line 40: Line 60:
##* Add Alias: ''Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks'' ##* Add Alias: ''Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks''
##* Save and exit. Make sure it '''does not''' Line-Wrap. ##* Save and exit. Make sure it '''does not''' Line-Wrap.
-# Restart '''Web Sharing''' so Apache re-reads the new configuration information.+ 
 +* Restart '''Web Sharing''' so Apache re-reads the new configuration information.
==Enabling User CGI Support== ==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.+You want ''http://localhost/~janbuck/cgi-bin/musicpad.cgi'' [http://l01c.ouvaton.org/musicpad-help.html] to do more than just serve up the text of a Perl script.
# Determine the full path to the directory you want to have Executable content # Determine the full path to the directory you want to have Executable content
Line 50: Line 71:
#* Terminal: '''pwd''' #* Terminal: '''pwd'''
#** Result: ''/Users/janebuck/Sites/cgi-bin'' #** Result: ''/Users/janebuck/Sites/cgi-bin''
-# Uncomment: ''#AddHandler cgi-script .cgi''+# Edit '''/etc/apache2/httpd.conf'''
-# Configure the user cgi-bin to be Executable, add this block of text:+## Uncomment: ''AddHandler cgi-script .cgi''
- <Directory /Users/janebuck/Sites/cgi-bin>+## Configure ''/Users/janebuck/Sites/cgi-bin'' to be Executable:
- Options Indexes FollowSymlinks MultiViews '''ExecCGI'''+ <Directory /Users/janebuck/Sites/cgi-bin>
- AllowOverride None+ Options Indexes FollowSymlinks MultiViews '''ExecCGI'''
- Order allow,deny+ AllowOverride None
- Allow from all+ Order allow,deny
- </Directory>+ Allow from all
 + </Directory>
-==Enabling PHP Support==+* Restart '''Web Sharing''' so Apache re-reads the new configuration information.
- +
-# Terminal: '''sudo vi /etc/apache2/httpd.conf'''+
-#* Uncomment: ''LoadModule php5_module libexec/apache2/libphp5.so''+
-#** vi (find the ''php5'' string): '''/php5'''+
-#** vi (move to the start of the line): '''^'''+
-#** vi (erase the ''#'' character): '''x'''+
-#** vi (colon character, '''w'''rite and '''q'''uit): ''':wq'''+
-# GUI Editor Alternative: '''sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/apache2/httpd.conf'''+
-#* Erase the '''#''' in front of the ''LoadModule php5_module libexec/apache2/libphp5.so'' line.+
-#* Save and exit. Make sure it '''does not''' Line-Wrap.+
-# Reboot so apache starts up fresh.+
=References= =References=
* System Preferences Help (?) * System Preferences Help (?)
 +* [http://l01c.ouvaton.org/musicpad-help.html musicpad.cgi]
[[Category:Project]] [[Category:MacOSXHack]] [[Category:Project]] [[Category:MacOSXHack]]

Current revision

Contents

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. User-Specific

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
    • Uncomment: LoadModule php5_module libexec/apache2/libphp5.so
      • vi (find the php5 string): /php5
      • vi (move to the start of the line): ^
      • vi (erase the # character): x
      • vi (colon character, write and quit): :wq
  2. GUI Editor Alternative: sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/apache2/httpd.conf
    • Erase the # in front of the LoadModule php5_module libexec/apache2/libphp5.so line.
    • 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
    • Terminal: cd ~/Sites/MacOSXHacks/
    • Terminal: pwd
      • Result: /Users/janebuck/Sites/MacOSXHacks
  2. Add Alias: Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks
    1. Terminal: sudo vi /etc/apache2/httpd.conf
      • vi (find the IfModule alias_module string): /IfModule alias_module
        • Moves to Line: <IfModule alias_module>
      • vi (insert after current line): o
      • vi (type in alias text):
        • Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks
      • vi (exit edit mode with Esc key): <Esc>
      • vi (colon character, write and quit): :wq
    2. GUI Editor Alternative: sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/apache2/httpd.conf
      • Locate: <IfModule alias_module>
      • Add Alias: Alias /MacOSXHacks /Users/janebuck/Sites/MacOSXHacks
      • 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 [1] to do more than just serve up the text of a Perl script.

  1. Determine the full path to the directory you want to have Executable content
    • Terminal: cd ~/Sites/cgi-bin/
    • Terminal: pwd
      • Result: /Users/janebuck/Sites/cgi-bin
  2. Edit /etc/apache2/httpd.conf
    1. Uncomment: AddHandler cgi-script .cgi
    2. Configure /Users/janebuck/Sites/cgi-bin to be Executable:
<Directory /Users/janebuck/Sites/cgi-bin>
 Options Indexes FollowSymlinks MultiViews ExecCGI
 AllowOverride None
 Order allow,deny
 Allow from all
</Directory>
  • Restart Web Sharing so Apache re-reads the new configuration information.

References

Personal tools