Source:
https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install httpd
brew services start httpd
sudo brew services start httpd
brew services restart httpd
brew services stop httpd
brew services start httpd
brew services restart httpd
code /usr/local/etc/httpd/httpd.conf
-
Tìm dòng
Listen 8080 -
Sửa thành
Listen 80
-
Tìm dòng
DocumentRoot "/usr/local/var/www" -
Sửa thành
DocumentRoot "/Users/hoangnamitc/Sites"
<Directory "/Users/hoangnamitc/Sites">
- Phân quyền
-
Tìm dòng
AllowOverride None -
Sửa thành
AllowOverride All
- Bật Mode rewrite
- Tìm dòng
mod_rewrite.so
bỏ dấu '#' phía trước dòng đó
- Phân quyền
-
tìm dòng
Group _www -
Sửa thành
User hoangnamitc
Group staff
-
Tìm dòng
#ServerName www.example.com:8080 -
Sửa thành
ServerName localhost
Hoàn thành
brew services stop httpd
brew services start httpd
Những trường hợp không chạy:
- Chưa tạo thư mục Sites/
- Thử lệnh sau:
httpd -k start
brew services list
Gặp lỗi:
httpd error 256 root
Chạy lệnh sau:
sudo launchctl bootout system /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
sudo brew services start httpd