- 追加された行はこの色です。
- 削除された行はこの色です。
&tag(MacPorts/apache2);
*目次 [#ub3be697]
#contents
*参考情報 [#m9e28149]
-[[MacPorts]]
-[[MacPortsでApache2をインストール -- BONNOH FRACTION 13:http://www.fraction.jp/log/archives/2007/11/02/Leopard_de_Apache2]]
*インストール [#d5bf5ed5]
-portコマンドでインストール
sudo port install apache2
-自動起動設定
sudo port load apache2
*設定 [#oafa1f67]
**httpd.confの作成 [#xba2b819]
-httpd.conf.sampleをコピーする
$ cd /opt/local/apache2/conf
$ sudo cp httpd.conf.sample httpd.conf
**ユーザーディレクトリを有効にする。 [#x3df4c5b]
-httpd.confで以下の部分のコメントを外す
# User home directories
Include conf/extra/httpd-userdir.conf
-httpd-userdir.confは以下のようになっている。/Users/ユーザー名/Sites以下にコンテンツを作れば良いことが分かる。
#pre{{
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>
}}
*起動 [#j86210ea]
-apachectrlコマンドを使う
$sudo /opt/local/apache2/bin/apachectl start
*停止 [#i53615fe]
-apachectrlコマンドを使う
$sudo /opt/local/apache2/bin/apachectl stop
*動作確認 [#ld85a673]
-http://localhost/にアクセスする。
*自動起動するようにする [#nf3c0b86]
自動起動用の設定ファイルが/Library/LaunchDaemons/org.macports.apache2.plistに保存されている。
-launchctlコマンドを使う。
$sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
*自動起動を停止する [#nf3c0b86]
-launchctlコマンドを使う。
$sudo launchctl unload -w /Library/LaunchDaemons/org.macports.apache2.plist
*Tips [#hf70b269]
**rubyでcgi [#aeaffcd7]
-/opt/local/apache2/cgi-bin/test.rbを編集
#pre{{
#!/opt/local/bin/ruby
require "cgi"
print "Content-type: text/html\n\n"
print "<html><body>Hello World</body></html>"
}}
-$ sudo chmod 755 test.rb
-http://localhost/cgi-bin/test.rb にアクセス。