M1 MacにHomebrewでApacheとPHPをインストールする方法メモ:
brew install httpd brew install php
設定ファイル:
/opt/homebrew/etc/httpd/httpd.conf
PHPを動かすための設定:
User ユーザー名 Group staff ... DirectoryIndex index.html index.php ... <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> ... LoadModule php_module /opt/homebrew/Cellar/php/8.0.12/lib/httpd/modules/libphp.so ...
必要に応じてエイリアスを設定:
Alias /hoge /Users/ユーザー名/hoge <Directory "/Users/ユーザー名/hoge"> Require all granted </Directory>
サービスに登録しつつ、Apacheを起動する方法:
sudo brew services start php sudo brew services start httpd
停止する場合:
sudo brew services stop httpd
macOS(Catalina)にHomebrewでApacheとPHPをインストールしようとしたら、結構変わっていて苦戦したのでメモ。
brew install apache2 brew install php
設定ファイル:
/usr/local/etc/httpd/httpd.conf
PHPを動かすための設定:
User ユーザー名 Group staff ... DirectoryIndex index.html index.php ... <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> <IfModule php7_module> AddType application/x-httpd-php .php </IfModule> ... LoadModule php7_module /usr/local/lib/httpd/modules/libphp7.so
必要に応じてエイリアスを設定:
Alias /repos /Users/ユーザー名/hoge <Directory "/Users/ユーザー名/hoge"> Require all granted </Directory>
サービスに登録しつつ、Apacheを起動する方法:
sudo brew services start httpd
停止する場合:
sudo brew services stop httpd
メモ: