記錄一下在Mac安裝nginx

安裝之前可以看一看自己的機器上是否已安裝,在命令行輸入ps -ef | grep nginx,出現:

    0 21608     1   0  3:27PM ??         0:00.00 nginx: master process nginx

   -2 21609 21608   0  3:27PM ??         0:00.00 nginx: worker process

  501 21611 13581   0  3:28PM ttys001    0:00.00 grep nginx

沒裝的話就只有最後一行了

先安裝brew,運行 brew -v 檢查, 安裝好了的話會有類似顯示:

Homebrew 2.2.6

Homebrew/homebrew-core (git revision 6bc24; last commit 2020-02-20)

此時我的機器上還什麼都沒有,網上找了下安裝過程:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)

brew install nginx

不過不幸的是ruby這行運行就報錯了:

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation

百度到了解決方法(摘自CSDN博主「jameskaron」,原文地址 https://blog.csdn.net/jameskaron/article/details/84923370):

先在瀏覽器輸入這個地址:https://raw.githubusercontent.com/Homebrew/install/master/install
看是否能打開,不能打開就是你網絡有問題,不要問我哦。

能打開如下:
把這個網頁保存名爲brew_install.rb的文件,保存的位置你隨便,只要自己能找到。

則在終端輸入curl
$ curl
curl: try 'curl --help' or 'curl --manual' for more information
這樣就沒錯,要是報錯,那我就不知道了!
然後在終端進入存放這個文件的目錄(這個不用我教吧),然後終端輸入
ruby brew_install.rb
然後等安裝homebrew吧!

嗯,感謝jameskaron仁兄,但是安裝還是失敗了。。。這次換了個錯誤:


Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-core /usr/local/Library/Taps/homebrew/homebrew-core --config core.autocrlf=false --depth=1 -q
Error: Failure while executing: /usr/local/bin/brew tap homebrew/core -q

找了下解決方案:https://blog.csdn.net/auccy/article/details/54620454

概括而言就是運行兩個命令:

 localhost:~ sant$ sudo chown -R apple:staff *
 localhost:~ sant$ brew doctor

其中apple替換爲自己的當前用戶名。

這次終於安裝成功了,brew安裝好後,nginx也順利安裝成功。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章