MAC上安裝Homebrew、Nginx、PHP、MySQL


准備工作

新版的 Mac OS 內置了Apache 和 PHP,可以通過以下命令查看Apache和PHP的版本號:

# httpd -v

# php -v

安裝Homebrew

Mac下的Homebrew相當於Linux下的apt-get、yum,可以獲得最新版的各種安裝包。

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

安裝完成后,運行以下命令檢查是否安裝成功

brew doctor

更新、升級下brew源

brew update && brew upgrade

安裝Nginx

brew install nginx

修改配置文件

sudo vim /usr/local/etc/nginx/nginx.conf
    #修改默認的8080端口為80

設置自啟

sudo cp -v /usr/local/opt/nginx/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/

啟動nginx服務

sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

現在默認監聽80端口,運行以下命令測試

curl -IL http://127.0.0.1:80

查看nginx幫助

nginx -h

停止Nginx服務

sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

安裝PHP

通過 brew 安裝不同版本的php

# brew tap homebrew/dupes
# brew tap homebrew/php
# brew tap josegonzalez/homebrew-php

安裝PHP7

# brew install php70 --with-fpm --with-mysql

設置自啟

sudo cp -v /usr/local/opt/nginx/homebrew.mxcl.php70.plist /Library/LaunchDaemons/

啟動php服務

sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.php70.plist

安裝MySQL

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM