0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Apache】初級備忘録

Posted at

初めに

こんにちは、Apache初心者です。
Apacheを実際にさわっていく上で基本的なところをまとめました。
macOSです。

Apacheがどういったものなのかという内容は含みません。

1. インストール

  • インストール
brew install httpd

ApacheはmacOSで標準搭載されているが、標準のものは署名していないプログラムを起動しないようになっており、PHPのモジュールがひっかかってしまうため、brew版をinstallする。

  • 確認
httpd -v

2. 設定ファイル

  • 設定ファイルの場所
    /usr/local/etc/httpd/httpd.conf

設定ファイルで最低限知っておきたいとこ

  • ポート
httpd.conf
Listen 80
  • 公開するフォルダ
httpd.conf
DocumentRoot "/usr/local/var/www"

3. コマンド

3.1. 基本

httpdコマンドの-kでプロセスの管理をする。
特権ポート(例えば80番ポート)を使用する場合はsudoが必要。

Apacheの起動

httpd -k start

アクセス先: http://localhost

Apacheの停止

httpd -k stop

Apacheの再起動

httpd -k restart

3.2. 設定ファイルのチェック

設定ファイルにシンタックスエラーがないか確認するコマンド。
再起動前に必ず確認する。

httpd -t

3.3. brew serviceをつかった場合

brew serviceコマンドで起動することで、サーバーを再起動した場合に自動的にApacheを起動してくれる。

いちいち起動する手間が減って便利だが、常にバックグラウンドで動かれてメモリやCPUリソースを使うので、ずっと起動しておく必要がなければhttpdコマンドを使う。

Apacheの起動

brew services start httpd

Apacheの停止

brew services stop httpd

Apacheの再起動

brew services restart httpd

Apacheのステータス確認

brew services list

参考文献

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?