How Mac uses the brew command to install PHP7 environments

Source: Internet
Author: User
Tags fpm ini install homebrew memcached redis versions zend

In recent years has been in the LNMP environment for development, which PHP or 5.5 version, a bit old, last December PHP7 has been officially released, added some syntax features, the biggest bright spot is the performance of the promotion, so always want to upgrade to the PHP7, due to the time relationship has been dragged to the present. The latest version of PHP to write this article is: 7.0.9 stable, so the stability of the basic need not worry.

Previously written Mac install LNMP environment is installed with brew, this upgrade PHP7 continue to use brew, install/upgrade software is very convenient.

Upgrading brew

Brew Update
Configuration

Brew Tap Homebrew/dupes
Brew Tap Homebrew/versions
Brew Tap homebrew/homebrew-php
Install PHP7

Brew Install PHP70
Problems encountered

Installation tips:

➜~ Brew Install Php70
==> installing PHP70 from homebrew/php
Error:cannot install HOMEBREW/PHP/PHP70 because conflicting formulae.

Php55:because different PHP versions install the same binaries.

Please ' Brew unlink php55 ' before continuing.

Unlinking removes a formula ' s symlinks from/usr/local. You can
Link the formula again after the install finishes. Can--force this
Install, but the build may fail or cause obscure side-effects in the
Resulting software.
Follow the prompts: Brew unlink Php55
Continue Setup: Brew Install PHP70

Configuration file

The configuration files that have been installed are all in the/usr/local/etc/php/7.0 directory, respectively, as follows:

Php.ini/usr/local/etc/php/7.0/php.ini
Php-fpm.conf/usr/local/etc/php/7.0/php-fpm.conf
PHP, Phpize, Php-config Ls/usr/local/opt/php70/bin
php-fpm/usr/local/opt/php70/sbin/php-fpm

Join power-on Boot

Mkdir-p ~/library/launchagents
Ln-sfv/usr/local/opt/php70/homebrew.mxcl.php70.plist ~/library/launchagents/
Launchctl load-w ~/library/launchagents/homebrew.mxcl.php70.plist
Command-line configuration

Vim ~/.ZSHRC
Will
Export Path= "$ (Brew--prefix php55)/bin: $PATH"
Replaced by
Export Path= "$ (Brew--prefix homebrew/php/php70)/bin: $PATH"

Alias php-fpm.start= "Launchctl load-w ~/library/launchagents/homebrew.mxcl.php55.plist"
Alias php-fpm.stop= "Launchctl unload-w ~/library/launchagents/homebrew.mxcl.php5.plist"
Alias php-fpm.restart= ' php-fpm.stop && php-fpm.start '
Amended to

Alias php-fpm.start= "Launchctl load-w ~/library/launchagents/homebrew.mxcl.php70.plist"
Alias php-fpm.stop= "Launchctl unload-w ~/library/launchagents/homebrew.mxcl.php70.plist"
Alias php-fpm.restart= ' php-fpm.stop && php-fpm.start '
Reload configuration file

SOURCE ~/.ZSHRC
Verify version

PHP version

➜~/usr/local/opt/php70/bin/php-v
PHP 7.0.9 (CLI) (Built:jul 2016 14:50:47) (NTS)
Copyright (c) 1997-2016 the PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
PHP-FPM version

➜~/usr/local/opt/php70/sbin/php-fpm-v
PHP 7.0.9 (fpm-fcgi) (Built:jul 21 2016 14:50:51)
Copyright (c) 1997-2016 the PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
Start PHP-FPM

Executive: Php-fpm.start

Check for successful startup:

➜~ PS Aux|grep php-fpm
Qloog 60380 0.2 0.0 2432792 604 s001 r+ 6:00pm 0:00.00 grep--color=auto--exclude-dir=.bzr--exclu De-dir=cvs--exclude-dir=.git--exclude-dir=.hg--exclude-dir=.svn php-fpm
Qloog 60378 0.0 0.0 2473348 620?? S 6:00pm 0:00.00/usr/local/opt/php70/sbin/php-fpm--fpm-config/usr/local/etc/php/7.0/php-fpm.conf
Qloog 60377 0.0 0.0 2473348 648?? S 6:00pm 0:00.00/usr/local/opt/php70/sbin/php-fpm--fpm-config/usr/local/etc/php/7.0/php-fpm.conf
Qloog 60372 0.0 0.0 2475396 7844?? S 6:00pm 0:00.03/usr/local/opt/php70/sbin/php-fpm--fpm-config/usr/local/etc/php/7.0/php-fpm.conf
Install extension

Yaf

Brew Install Php70-yaf

Configuration file
/usr/local/etc/php/7.0/conf.d/ext-yaf.ini

Memcached

Brew Install php70-memcached

Configuration file
/usr/local/etc/php/7.0/conf.d/ext-memcached.ini

Redis

Brew Install Php70-redis

Configuration file
/usr/local/etc/php/7.0/conf.d/ext-redis.ini

Xdebug

Brew Install Php70-xdebug

Configuration file
/usr/local/etc/php/7.0/conf.d/ext-xdebug.ini

Swoole

Brew Install Php70-swoole

Configuration file
/usr/local/etc/php/7.0/conf.d/ext-swoole.ini

More Extensions perform brew install extensions for installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.