Mac安装Nginx及域名IP映射配置
一、安装Command Line tools
命令行安装未成功,可以手动下载安装
xcode-select –install
下载地址 https://developer.apple.com/download/more/
搜索command line tools,下载xcode对应的版本。xcode版本查看xcodebuild -version
二、安装Nginx
brew install Nginx
三、域名IP映射配置示例
配置文件路径 /usr/local/etc/Nginx/Nginx.conf
将abc.def.com的请求转到127.0.0.1 8888端口
server {
listen 80;
server_name abc.def.com;
location / {
proxy_pass http://127.0.0.1:8888;
}
}
将jkl.xxx.com/abc的请求转到127.0.0.1 9999端口
server {
listen 80;
server_name jkl.xxx.com;
location /abc/ {
proxy_pass http://127.0.0.1:9999/;
}
}
四、启动Nginx
sudo Nginx