&tag(MacPorts/apache2);
sudo port install apache2
sudo port load apache2
$ cd /opt/local/apache2/conf $ sudo cp httpd.conf.sample httpd.conf
# User home directories Include conf/extra/httpd-userdir.conf
UserDir Sites
#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
<Directory "/Users/*/Sites">
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
$sudo /opt/local/apache2/bin/apachectl start
$sudo /opt/local/apache2/bin/apachectl stop
自動起動用の設定ファイルが/Library/LaunchDaemons/org.macports.apache2.plistに保存されている。
$sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
$sudo launchctl unload -w /Library/LaunchDaemons/org.macports.apache2.plist
#!/opt/local/bin/ruby require "cgi" print "Content-type: text/html\n\n" print "<html><body>Hello World</body></html>"