macOS 標準 Apache 起動マニュアル

1. 基本コマンド

※ 標準 Apache は root 権限で動作するため sudo が必要です。

2. DocumentRoot の確認

設定ファイル /etc/apache2/httpd.conf を確認します。

DocumentRoot "/Library/WebServer/Documents"


    AllowOverride All
    Require all granted

ブラウザからアクセス可能な URL 例:

http://localhost/Library.html

3. 問題発生時の確認手順

  1. Apache が起動しているか確認:
    ps aux | grep httpd
    sudo lsof -i :80
  2. 設定ファイルにエラーがないか確認:
    sudo apachectl configtest
  3. ログで原因を確認:
    sudo tail -f /var/log/apache2/error_log

4. Homebrew 版 Apache 停止(競合回避)

brew services stop httpd
sudo pkill -9 -f /opt/homebrew/opt/httpd/bin/httpd