Skip to content

Instantly share code, notes, and snippets.

@hoangnamitc
Last active October 21, 2024 01:59
Show Gist options
  • Save hoangnamitc/46844048e50a61e186fd59588d5b2098 to your computer and use it in GitHub Desktop.
Save hoangnamitc/46844048e50a61e186fd59588d5b2098 to your computer and use it in GitHub Desktop.
Source: https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions
------------------------------------------------------------------------------------------------
# Tắt Apache mặc định của OSX
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
------------------------------------------------------------------------------------------------
# Cài Apache mới
HOMEBREW_NO_AUTO_UPDATE=1 brew install httpd
------------------------------------------------------------------------------------------------
# Khởi động Apache mới
brew services start httpd
# Khởi động cùng máy
sudo brew services start httpd
# Restart Apache mới
brew services restart httpd
# DS lệng liên quan
brew services stop httpd
brew services start httpd
brew services restart httpd
------------------------------------------------------------------------------------------------
# Thay đổi port 8080 thành 80
code /usr/local/etc/httpd/httpd.conf
# Tìm dòng
Listen 8080
# Sửa thành
Listen 80
------------------------------------------------------------------------------------------------
# Thay đổi thư mục lưu code
# 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
------------------------------------------------------------------------------------------------
# Lưu ý:
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
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment