LeopardでCGIを利用するまでの設定
少しハマった。
原因はLeopardからApacheが1.3系から2系に変わったこと。
これ注意。
まず、以下のどちらかのファイルを編集すれば良いらしい。
- /private/etc/apache2/httpd.conf
- /private/etc/apache2/users/"ユーザ名".conf
今回は、"ユーザ名".confを編集することに。
ファイルの編集
ホームディレクトリに持ってくる。
$ cp /private/etc/apache2/users/rdera.conf .
編集用とバックアップ用を用意する。
$ cp ./rdera.conf ./rdera.conf.bak
編集用ファイルrdera.confを変更
変更前
1 <Directory "/Users/rdera/Sites/"> 2 Options Indexes MultiViews 3 AllowOverride None 4 Order allow,deny 5 Allow from all 6 </Directory>
変更後
1 <Directory "/Users/rdera/Sites/"> 2 DirectoryIndex index.html index.cgi 3 Options ExecCGI Includes Indexes MultiViews 4 AddHandler cgi-script .cgi 5 AllowOverride None 6 Order allow,deny 7 Allow from all 8 </Directory>
設定ファイルを上書き
$ sudo mv rdera.conf /private/etc/apache2/users/rdera.conf
Apacheの起動
二通りの方法がある。
- コマンドラインから
- システム環境設定から
コマンドラインから
$ sudo apachectl start
システム環境設定から
システム環境設定→共有
Web共有のチェックボックスを『入』にする。
CGIテスト用のプログラムを作成
/Users/Sites以下にindex.cgiを作成
1 #! /opt/local/bin/perl 2 3 print STDOUT "Content-type: text/html\n\n"; 4 5 print <<END; 6 <html> 7 <head> 8 </head> 9 <body> 10 12345 11 </body> 12 <html> 13 END
パーミッションを変更
$ chmod 705 index.cgi