nishimura.clubnishimura.club

MacでApacheの操作

作成日
2021-06-21
更新日
2021-06-21

環境

  • macOS: BigSur 11.0.1

基本操作

sudo apachectl start # 起動 sudo apachectl restart # 再起動 sudo apachectl stop # 停止

インストールされているか確認

which httpd # => /usr/sbin/httpd

Controlllerの確認

which apachectl # => /usr/sbin/apachectl

バージョン確認

/usr/sbin/httpd -version # => Server version: Apache/2.4.46 (Unix)

デフォルトのドキュメントルート

/Library/WebServer/Documents/index.html.en

Apache設定ファイルの編集

sudo vim /etc/apache2/httpd.conf

Apache設定ファイルでよく確認する場所

DocumentRoot "/Users/username/hoge" <Directory /Users/username/hoge> AllowOverride All Require all granted </Directory> AccessFileName .htaccess

プロセスの確認

ps aux | grep httpd _www 58531 0.0 0.0 4338140 1020 ?? S 5:38PM 0:00.00 /usr/sbin/httpd -D FOREGROUND root 58500 0.0 0.1 4338176 8532 ?? Ss 5:37PM 0:00.27 /usr/sbin/httpd -D FOREGROUND

権限の変更

sudo chown -R _www:_www hoge/

ログの確認

tail -f /var/log/apache2/access_log tail -f /var/log/apache2/error_log

Related