【安裝 nginx】on Mac

sexyoung
進擊的 Tool’ s
2 min readJan 22, 2016

最近因為在製作個人網站,因為有使用到 node.js ,網路上又說搭配 nginx 比較好(好像不管哪個語言都這樣說),被迫只好來學一下 nginx。

在 Mac 裡只要這樣下就可以了。

brew install nginx

然後再下個

nginx

服務就跑起來了,打開瀏覽器 http://localhost:8080/

如果要是在 mac 用 brew 裝的話,在 /usr/local/etc/nginx/nginx.conf 這邊可以設定 nginx 的一些環境。

然後如果要 stop 服務,只要下個

nginx -s stop

服務就會關起來了。

打開設定檔,修改 root (網頁置放目錄),就可以把網頁放在你想放的地方囉

server {
listen 80;
server_name localhost;
#access_log logs/host.access.log main;location / {
root /Users/ben/www;
index index.html index.htm;
}
……

覺得簡單。

如果這文章有幫助到您,希望您也可以幫我按個讚!謝謝您

--

--