Apacheの起動と設定

Mavericksがやってきた - koba::blogの続き。Mavericksでは「システム環境設定」の「共有」に「Web共有」がありません。Apache自体はインストールされています*1が、起動は自分でやる必要があります。

Apacheの起動

とりあえず、以下のコマンドでApacheを起動してみます。

$ sudo apachectl start

http://localhost/ にアクセスすると、「It Works!」という素っ気ないページが表示されました。起動は成功。
Macの起動時にApacheも起動するためには、launchctl で登録します。

$ sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Apacheの設定

設定の要領は Apacheの設定を変更する - koba::blog と同じです。Apacheの設定ファイルは /etc/apache2/httpd.conf にあります。ユーザごとの設定は、users 配下に置くようになっています。すでに Guest アカウントの設定があるので、これをコピーして、公開ディレクトリを ~/Sites/ とし、 AllowOverride を All に変更します。

<Directory "/Users/koba/Sites/">
    Options Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

これで .htaccess が有効になりました。

.htaccess には以下の設定を行いました。

Options +ExecCGI
AddHandler cgi-script cgi

Options +Includes
Addtype text/html shtml
AddHandler server-parsed shtml

DirectoryIndex index.cgi index.shtml index.html

*1:Apacheのバージョンは 2.2.24