Mac下使用brew搭建PHP7+nginx+mysql開發環境


http://blog.csdn.net/mysteryhaohao/article/details/52230634

 

HomeBrew

brew的安裝,直接上官網:http://brew.sh/ 

一個命令就搞定:

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

 

PHP7

安裝好brew之后,先安裝php7。安裝php7之前,要先更新一下brew的源並加入一些第三方的庫:

brew update

brew tap homebrew/dupes

brew tap homebrew/versions

brew tap homebrew/homebrew-php

然后就可以使用brew搜索php70的包並安裝了

brew search php70

brew install php70

至於php70的擴展安裝,在search的時候就已經有擴展的列表的,按需安裝,安裝也很簡單:

brew install php70-redis

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.2/

To have launchd start php now and restart at login:
  brew services start php
Or, if you don't want/need a background service you can just run:
  php-fpm

 

Nginx

同php7一樣:

brew install nginx

安裝好后,如果要加入到自啟動的話,要先添加一個文件夾:

mkdir -p ~/Library/LaunchAgents

然后把自啟動的plist加入到這個文件夾內:

cp /usr/local/Cellar/nginx/1.10.1/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents

然后執行mac的launchctl命令就可以了:

launchctl -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

如果把php也加入自啟動的話,也是一樣的吧Cellar/php下面的plist加入到LaunchAgents文件夾下並執行launchctl命令即可

 

Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

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

 

Mysql

安裝一樣簡單:

brew install mysql

安裝好之后,執行mysql.server start

這時候要記得,使用mysql_secure_installration來對mysql進行安全設置,包括設置root密碼以及密碼安全級別等

  We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start


免責聲明!

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



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