#安装php56,下面是可加参数 ### --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 --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 ### #执行命令,这边直接可以在后面加参数 这边是直接加上apache参数(提示这里用osx10.12的apache时也要安装),会有 libexec.so直接生成 如果你不想 下图有下载链接 你可以直接下载 brew install php56 --with httpd24
###提示 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/php56)/bin:$PATH" ✩✩✩✩ FPM ✩✩✩✩ To launch php-fpm on startup: mkdir -p ~/Library/LaunchAgents cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist The control script is located at /usr/local/opt/php56/sbin/php56-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.php56.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 php56 for more details. To have launchd start homebrew/php/php56 now and restart at login: brew services start homebrew/php/php56
#执行 php -v 可能出现以下提示,是因为brew编译的扩展和php官网扩展不一致导致的。 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php56-mcrypt/mcrypt.so' - dlopen(/usr/local/opt/php56-mcrypt/mcrypt.so, 9): Library not loaded: /usr/local/opt/libtool/lib/libltdl.7.dylib Referenced from: /usr/local/opt/php56-mcrypt/mcrypt.so Reason: image not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php56-mcrypt/mcrypt.so' - dlopen(/usr/local/opt/php56-mcrypt/mcrypt.so, 9): Library not loaded: /usr/local/opt/libtool/lib/libltdl.7.dylib Referenced from: /usr/local/opt/php56-mcrypt/mcrypt.so Reason: image not found in Unknown on line 0 PHP 5.6.30 (cli) (built: Mar 11 2017 09:56:27) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies