前の記事「“macOS(15.2)SequoiaでMAMP:[Homebrew]の再インストール」において「新しいiMac(Sequoia, Apple M4)」に「Homebrew」を再インストールしました。この記事では、その再インストールしたHomebrewでApacheをインストールしたた際のログを記載しています。
[HomeBrew]Apacheのインストール
「brew install httpd」コマンドでApache2.4(httpd)をインストールしました。
% brew install httpd : ==> httpd DocumentRoot is /opt/homebrew/var/www. The default ports have been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in /opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo. To restart httpd after an upgrade: brew services restart httpd Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND % brew services stop httpd : ==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd) % brew services start httpd ==> Successfully started `httpd` (label: homebrew.mxcl.httpd) % brew services restart httpd ==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd) ==> Successfully started `httpd` (label: homebrew.mxcl.httpd) % launchctl list|grep httpd 5352 0 homebrew.mxcl.httpd % httpd -V Server version: Apache/2.4.62 (Unix) : -D SERVER_CONFIG_FILE="/opt/homebrew/etc/httpd/httpd.conf"
Apacheの設定(httpd.conf)の編集
HomebrewでインストールしたApacheを設定するファイルは、「httpd -V」コマンドで表示される”/opt/homebrew/etc/httpd/httpd.conf”です。エディタ(nano)をroot権限で使用(sudo)して「httpd.conf」の修正を行いました。
% sudo nano /opt/homebrew/etc/httpd/httpd.conf
HomebrewでインストールしたApacheは、ポート番号が「8080」で起動するようになっていましたので、「ポート番号が「80」で起動するように変更しました。
#-# Listen 8080 Listen 80
ServerNameを「 www.example.com:8080」から「localhost」に変更しました。
#-# ServerName www.example.com:8080 ServerName localhost
rewriteを使用することができるようにするために、以下の記述をコメントアウトしてモジュールを組み込みました。
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
デフォルトのDocumentRoot「”/opt/homebrew/var/www”」を「”/Users/{username}/LocalSites/”」に変更し、AllowOverrideの設定を「None」から「All」に変更しました。({username}は、iMacのログインユーザーネームです。)
#-# DocumentRoot "/opt/homebrew/var/www" DocumentRoot "/Users/{username}/LocalSites/" #-# <Directory "/opt/homebrew/var/www"> <Directory "/Users/{username}/LocalSites/"> : #-# AllowOverride None AllowOverride All : </Directory>
「brew services restart httpd」コマンドで、httpdを再起動しました。
% brew services restart httpd Stopping `httpd`... (might take a while) ==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd) ==> Successfully started `httpd` (label: homebrew.mxcl.httpd) %
「”/Users/{username}/LocalSites/”」フォルダに新規作成した「index.html」がブラウザで表示できることを確認しました。
<html> <body> <!-- index.html --> <h1>LocalSites works!</h1> </body> </html>
[HomeBrew]Apacheの起動、再起動と停止
以下のコマンドで[HomeBrew]Apacheの起動、再起動と停止を確認しました。
- [HomeBrew]Apacheを再起動します。
% brew services restart httpd Stopping `httpd`... (might take a while) ==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd) ==> Successfully started `httpd` (label: homebrew.mxcl.httpd) %
- [HomeBrew]Apacheを停止します。
% brew services stop httpd Stopping `httpd`... (might take a while) ==> Successfully stopped `httpd` (label: homebrew.mxcl.httpd) %
- [HomeBrew]Apacheを起動します。
% brew services start httpd : ==> Successfully started `httpd` (label: homebrew.mxcl.httpd) %
Apacheの起動、再起動と停止を確認して、Apache2.4のインストールを完了しました。次は、PHPのインストールです。
macOS(15.2)SequoiaでMAMP:関連記事
- macOS(15.2)SequoiaでMAMP:[Homebrew]の再インストール
- macOS(15.2)SequoiaでMAMP:[Homebrew]Apacheのインストール(この記事)
- macOS(15.2)SequoiaでMAMP:[HomeBrew]PHPのインストール
- macOS(15.2)SequoiaでMAMP:[Homebrew]MariaDBのインストール
- macOS(15.2)SequoiaでMAMP:[Homebrew]phpMyAdminのインストール
コメント