第一次在Mac上安裝NMP,記錄下
因為下面環境的安裝都是基於homebrew的,所以如果沒有安裝他的話,要先安裝他(官網:https://brew.sh/index_zh-cn.html)
- 安裝homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
等待安裝即可
- 安裝nginx
brew install nginx
注意:安裝過程中會將一些安裝的信息告訴你,省的你到處找:
Docroot is: /usr/local/var/www
nginx will load all files in /usr/local/etc/nginx/servers/The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.To have launchd start nginx now and restart at login:
brew services start nginx
Or, if you don't want/need a background service you can just run:
nginx
等。
安裝成功,啟動Nginx:sudo nginx
啟動成功后,測試是否成功:
curl -IL http://127.0.0.1:8080
不出意外的話,得到的信息:
HTTP/1.1 200 OK Server: nginx/1.15.12 Date: Tue, 21 May 2019 07:17:40 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Tue, 16 Apr 2019 14:55:03 GMT Connection: keep-alive ETag: "5cb5ecc7-264" Accept-Ranges: bytes
其他命令:
#打開 nginx sudo nginx #重新加載配置|重啟|停止|退出 nginx nginx -s reload|reopen|stop|quit #測試配置是否有語法錯誤 nginx -t
設置開機啟動:
cp /usr/local/Cellar/nginx/1.2.6/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/ 3 launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
- Mysql安裝
brew install mysql
執行完后,就可以在終端里運行 "mysql",直接進入mysql數據庫里。對,不用輸入密碼,可以直接連接,初始默認是可以匿名訪問的。超級用戶 "root" 也是沒設密碼,要設密碼的話可以執行下面指令
/usr/local/opt/mysql/bin/mysqladmin -u root password 'new-password'
現在訪問 mysql 還是不用密碼就可以連接,如果要設置一些登陸密碼的安全訪問限制,則需執行下面的 mysql安全安裝指令
/usr/local/opt/mysql/bin/mysql_secure_installation
主要是設置修改root密碼(設置過了可以不用設置,略過)、刪除匿名訪問、刪除root網絡訪問、刪除test數據庫。指令執行完后,登陸mysql就需要密碼驗證了
mysql -u root -p
設置開機啟動“
cp /usr/local/Cellar/mysql/5.5.28/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
至此,mysql安裝完畢。
安裝php-fpm
因為篇幅太長,所以單獨寫了一篇文章,參考Mac安裝PHP(Homebrew/php棄用、其他第三方tap也已經棄用或者遷移后的安裝配置方案)