$ brew tap homebrew/dupes && \ $ brew tap homebrew/php
$ brew install php71 ==> Installing php71 from homebrew/php ==> Downloading https://homebrew.bintray.com/bottles-php/php71-7.1.1_12.sierra.bottle.tar.gz ######################################################################## 100.0% ==> Pouring php71-7.1.1_12.sierra.bottle.tar.gz ==> Caveats The php.ini file can be found in: /usr/local/etc/php/7.1/php.ini
✩✩✩✩ Extensions ✩✩✩✩
If you are having issues with custom extension compiling, ensure that you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:
PATH="/usr/local/bin:$PATH"
PHP71 Extensions will always be compiled against this PHP. Please install them using --without-homebrew-php to enable compiling against system PHP.
✩✩✩✩ PHP CLI ✩✩✩✩
If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file:
To launch php-fpm on startup: mkdir -p ~/Library/LaunchAgents cp /usr/local/opt/php71/homebrew.mxcl.php71.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php71.plist
The control script is located at /usr/local/opt/php71/sbin/php71-fpm
OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:
PATH="/usr/local/sbin:$PATH"
You may also need to edit the plist to use the correct "UserName".
Please note that the plist was called 'homebrew-php.josegonzalez.php71.plist' in old versions of this formula.
With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system you have to install php with the --with-httpd24 option. See brew options php71 for more details.
To have launchd start homebrew/php/php71 now and restart at login: brew services start homebrew/php/php71 ==> Summary 🍺 /usr/local/Cellar/php71/7.1.1_12: 344 files, 39.7M
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 ==> Summary 🍺 /usr/local/Cellar/nginx/1.12.1: 23 files, 1MB
安裝測試 Testing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
## Start Nginx $ sudo brew services start nginx
## Check if Nginx is running on default port $ curl -IL http://127.0.0.1:8080 curl -IL http://127.0.0.1:8080 HTTP/1.1 200 OK Server: nginx/1.12.1 Date: Sun, 27 Aug 2017 14:59:30 GMT Content-Type: text/html Content-Length: 274 Last-Modified: Sat, 26 Aug 2017 14:05:36 GMT Connection: keep-alive ETag: "59a18030-112" Accept-Ranges: bytes
$ brew info php71 homebrew/php/php71: stable 7.1.8 (bottled), HEAD PHP Version 7.1 https://php.net Conflicts with: php53 (because different php versions install the same binaries.) php54 (because different php versions install the same binaries.) php55 (because different php versions install the same binaries.) php56 (because different php versions install the same binaries.) php70 (because different php versions install the same binaries.) php72 (because different php versions install the same binaries.) /usr/local/Cellar/php71/7.1.8_20 (349 files, 39.5MB) * Poured from bottle on 2017-08-26 at 16:34:27 From: https://github.com/Homebrew/homebrew-php/blob/master/Formula/php71.rb ==> Dependencies Required: freetype ✔, gettext ✔, icu4c ✔, jpeg ✔, libpng ✔, libxml2 ✔, unixodbc ✔, readline ✔, openssl ✔ Optional: enchant ✘, gmp ✘, webp ✘, homebrew/apache/httpd24 ✔, homebrew/apache/httpd22 ✘ ==> Requirements Optional: postgresql ✘ ==> Options --with-cgi Enable building of the CGI executable (implies --without-fpm) --with-debug Compile with debugging symbols --with-enchant Build with enchant support --with-gmp Build with gmp support --with-homebrew-curl Include Curl support via Homebrew --with-homebrew-libressl Include LibreSSL instead of OpenSSL via Homebrew --with-homebrew-libxml2 Include Libxml2 support via Homebrew --with-homebrew-libxslt Include LibXSLT support via Homebrew --with-httpd22 Enable building of shared Apache 2.2 Handler module --with-httpd24 Enable building of shared Apache 2.4 Handler module --with-imap Include IMAP extension --with-libmysql Include (old-style) libmysql support instead of mysqlnd --with-mssql Include MSSQL-DB support --with-pdo-oci Include Oracle databases (requries ORACLE_HOME be set) --with-pear Build with PEAR --with-phpdbg Enable building of the phpdbg SAPI executable --with-postgresql Build with postgresql support --with-thread-safety Build with thread safety --with-webp Build with webp support --without-bz2 Build without bz2 support --without-fpm Disable building of the fpm SAPI executable --without-ldap Build without LDAP support --without-legacy-mysql Do not include the deprecated mysql_ functions --without-mysql Remove MySQL/MariaDB support --without-pcntl Build without Process Control support --without-unixodbc Build without unixODBC support --HEAD Install HEAD version ==> Caveats The php.ini file can be found in: /usr/local/etc/php/7.1/php.ini
✩✩✩✩ Extensions ✩✩✩✩
If you are having issues with custom extension compiling, ensure that you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:
PATH="/usr/local/bin:$PATH"
PHP71 Extensions will always be compiled against this PHP. Please install them using --without-homebrew-php to enable compiling against system PHP.
✩✩✩✩ PHP CLI ✩✩✩✩
If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file: export PATH="$(brew --prefix homebrew/php/php71)/bin:$PATH"
✩✩✩✩ FPM ✩✩✩✩
To launch php-fpm on startup: mkdir -p ~/Library/LaunchAgents cp /usr/local/opt/php71/homebrew.mxcl.php71.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php71.plist
The control script is located at /usr/local/opt/php71/sbin/php71-fpm
OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:
PATH="/usr/local/sbin:$PATH"
You may also need to edit the plist to use the correct "UserName".
Please note that the plist was called 'homebrew-php.josegonzalez.php71.plist' in old versions of this formula.
With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system you have to install php with the --with-httpd24 option. See brew options php71 for more details.
To have launchd start homebrew/php/php71 now and restart at login: brew services start homebrew/php/php71
後記 Epilogue
如果 $ curl -IL http://127.0.0.1:8080 出現 curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused,請記得檢查
php-fpm 是不是啟動
nginx 是否有 restart
/usr/loca/etc/php/7.1/php-fpm.d/www.conf 內 user 及 group 是否正確設定