第一次在Mac上安裝NMP,記錄下php
由於下面環境的安裝都是基於homebrew的,因此若是沒有安裝他的話,要先安裝他(官網:https://brew.sh/index_zh-cn.html)html
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
等待安裝便可mysql
brew install nginx
注意:安裝過程當中會將一些安裝的信息告訴你,省的你處處找:
Docroot is: /usr/local/var/www
nginx will load all files in /usr/local/etc/nginx/servers/nginx
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
git
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:github
sudo nginx
啓動成功後,測試是否成功:sql
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
設置開機啓動:ruby
cp /usr/local/Cellar/nginx/1.2.6/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/ 3 launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
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也已經棄用或者遷移後的安裝配置方案)