Mac 安装php7.3和相关插件
安装PHP
通过Brew安装php
- 
搜索php 
 brew search php
- 
remvoe old php 
 brew remove php@7.1
- 
install php 7.3 
 brew install php@7.3
- 
安装成功信息: - 
php.ini and php-fpm.ini file can be found in: 
 /usr/local/etc/php/7.3/
- 
If you need to have php@7.3 first in your PATH run: 
 echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.zshrc
 echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.zshrc
- 
For compilers to find php@7.3 you may need to set: 
 export LDFLAGS="-L/usr/local/opt/php@7.3/lib"
 export CPPFLAGS="-I/usr/local/opt/php@7.3/include"
- 
launchd start php@7.3 now and restart at login: 
 brew services start php@7.3
 brew services restart php@7.3
 sudo php-fpm -D
 sudo pkill -9 php-fpm
 
- 
配置php环境变量
- 打开path文件
/private/etc/paths
- 添加php@7.3
    /usr/local/opt/php@7.3/bin
    /usr/local/opt/php@7.3/sbin
    /usr/local/opt/php@7.1/bin
    /usr/local/opt/php@7.1/sbin
    /usr/local/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/opt/mariadb@10.3/bin
    /usr/local/Cellar/node@10/10.17.0/bin
    /Users/zhoujh/Library/Android/sdk/tools
    /Users/zhoujh/Library/Android/sdk/platform-tools
查看php安装结果
- 重启termanal
- 查看php版本
- 命令:php -v
- 结果:
PHP 7.3.16 (cli) (built: Mar 19 2020 11:19:09) ( NTS ) 
 Copyright (c) 1997-2018 The PHP Group
 Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies
 with Zend OPcache v7.3.16, Copyright (c) 1999-2018, by Zend Technologies
 
- 命令:
安装php插件
安装 igbinary
- 
search pecl search igbinaryPackage Stable/(Latest) Local 
 igbinary 3.1.2 (stable) igbinary extension
- 
install pecl install igbinaryInstalling '/usr/local/Cellar/php@7.3/7.3.16/pecl/20180731/igbinary.so' 
 install ok: channel://pecl.php.net/igbinary-3.1.2
- 
查看安装 php -i | grep igbinaryigbinary support => enabled 
 igbinary version => 3.1.2
 igbinary APCu serializer ABI => no
 igbinary session support => yes
 igbinary.compact_strings => On => On
 Registered serializer handlers => php_serialize php php_binary wddx igbinary
安装 memcached
- 
search pecl search memcachedPackage Stable/(Latest) Local 
 memcached 3.1.5 (stable) PHP extension for interfacing with memcached via libmemcached library
- 
install pecl install memcachedlibmemcached directory [no] : yes 
 zlib directory [no] : no
 use system fastlz [no] : no
 enable igbinary serializer [no] : yes
 enable msgpack serializer [no] : no
 enable json serializer [no] : no
 enable server protocol [no] : no
 enable sasl [yes] : yes
 enable sessions [yes] : yescached-3.1.5/usr/local/Cellar/php@7.3/7.3.16/pecl/20180731/memcached.so 
 Build process completed successfully
 Installing '/usr/local/Cellar/php@7.3/7.3.16/pecl/20180731/memcached.so'
 install ok: channel://pecl.php.net/memcached-3.1.5
 Extension memcached enabled in php.ini
- 
查看安装 php -i | grep memcachedmemcached support => enabled
 libmemcached version => 1.0.18
 memcached.compression_factor => 1.3 => 1.3
 memcached.compression_threshold => 2000 => 2000
 memcached.compression_type => fastlz => fastlz
 memcached.default_binary_protocol => Off => Off
 memcached.default_connect_timeout => 0 => 0
 memcached.default_consistent_hash => Off => Off
 memcached.serializer => igbinary => igbinary
 memcached.sess_binary_protocol => On => On
 memcached.sess_connect_timeout => 0 => 0
 memcached.sess_consistent_hash => On => On
 memcached.sess_consistent_hash_type => ketama => ketama
 memcached.sess_lock_expire => 0 => 0
 memcached.sess_lock_max_wait => not set => not set
 memcached.sess_lock_retries => 5 => 5
 memcached.sess_lock_wait => not set => not set
 memcached.sess_lock_wait_max => 150 => 150
 memcached.sess_lock_wait_min => 150 => 150
 memcached.sess_locking => On => On
 memcached.sess_number_of_replicas => 0 => 0
 memcached.sess_persistent => Off => Off
 memcached.sess_prefix => memc.sess.key. => memc.sess.key.
 memcached.sess_randomize_replica_read => Off => Off
 memcached.sess_remove_failed_servers => Off => Off
 memcached.sess_sasl_password => no value => no value
 memcached.sess_sasl_username => no value => no value
 memcached.sess_server_failure_limit => 0 => 0
 memcached.store_retry_count => 2 => 2
 Registered save handlers => files user memcached
安装 redis
- 
search pecl search redisPackage Stable/(Latest) Local 
 redis 5.2.1 (stable) PHP extension for interfacing with Redis
- 
install pecl install redisenable igbinary serializer support? [no] : yes 
 enable lzf compression support? [no] : no
 enable zstd compression support? [no] : noBuild process completed successfully 
 Installing '/usr/local/Cellar/php@7.3/7.3.16/pecl/20180731/redis.so'
 install ok: channel://pecl.php.net/redis-5.2.1
 Extension redis enabled in php.ini
- 
查看安装 php -i | grep redisredis.arrays.algorithm => no value => no value 
 redis.arrays.auth => no value => no value
 redis.arrays.autorehash => 0 => 0
 redis.arrays.connecttimeout => 0 => 0
 redis.arrays.consistent => 0 => 0
 redis.arrays.distributor => no value => no value
 redis.arrays.functions => no value => no value
 redis.arrays.hosts => no value => no value
 redis.arrays.index => 0 => 0
 redis.arrays.lazyconnect => 0 => 0
 redis.arrays.names => no value => no value
 redis.arrays.pconnect => 0 => 0
 redis.arrays.previous => no value => no value
 redis.arrays.readtimeout => 0 => 0
 redis.arrays.retryinterval => 0 => 0
 redis.clusters.auth => no value => no value
 redis.clusters.cache_slots => 0 => 0
 redis.clusters.persistent => 0 => 0
 redis.clusters.read_timeout => 0 => 0
 redis.clusters.seeds => no value => no value
 redis.clusters.timeout => 0 => 0
 redis.pconnect.connection_limit => 0 => 0
 redis.pconnect.pooling_enabled => 1 => 1
 redis.session.lock_expire => 0 => 0
 redis.session.lock_retries => 10 => 10
 redis.session.lock_wait_time => 2000 => 2000
 redis.session.locking_enabled => 0 => 0
 Registered save handlers => files user redis rediscluster memcached
 This program is free software; you can redistribute it and/or modify
安装 xdebug
- 
search pecl search xdebugPackage Stable/(Latest) Local 
 xdebug 2.9.4 (stable) Provides functions for function traces and profiling
- 
install pecl install xdebugBuild process completed successfully 
 Installing '/usr/local/Cellar/php@7.3/7.3.16/pecl/20180731/xdebug.so'
 install ok: channel://pecl.php.net/xdebug-2.9.4
 Extension xdebug enabled in php.ini
- 
查看安装 php -i | grep xdebugxdebug support => enabled 
 Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support
 xdebug.auto_trace => Off => Off
 xdebug.cli_color => 0 => 0
安装 mongodb
- 
search pecl search mongodbPackage Stable/(Latest) Local 
 mongodb 1.8.0beta1 (beta) MongoDB driver for PHP
- 
install pecl install mongodbBuild process completed successfully 
 Installing '/usr/local/Cellar/php@7.3/7.3.16/pecl/20180731/mongodb.so'
 install ok: channel://pecl.php.net/mongodb-1.7.4
 Extension mongodb enabled in php.ini
- 
查看安装 php -i | grep mongodbmongodb 
 mongodb.debug => no value => no value
安装 swoole
- 
search pecl search swoolePackage Stable/(Latest) Local 
 swoole 4.4.17 (stable) Event-driven asynchronous and concurrent networking engine with high performance for PHP.
- 
查看openssl 类库地址 brew search opensslbrew info openssl@1.1/usr/local/Cellar/openssl@1.1/1.1.1f 
- 
install pecl install swooleenable sockets supports? [no] : yes 
 enable openssl support? [no] : yes --with-openssl-dir=/usr/local/Cellar/openssl@1.1/1.1.1f
 enable http2 support? [no] : yes
 enable mysqlnd support? [no] : yesBuild process completed successfully 
 Installing '/usr/local/Cellar/php@7.3/7.3.16/include/php/ext/swoole/config.h'
 Installing '/usr/local/Cellar/php@7.3/7.3.16/pecl/20180731/swoole.so'
 install ok: channel://pecl.php.net/swoole-4.4.17
 Extension swoole enabled in php.ini
- 
查看安装 php -i | grep swooleAuthor => Swoole Team <team@swoole.com>swoole.display_errors => On => On
 swoole.enable_coroutine => On => On
 swoole.enable_library => On => On
 swoole.enable_preemptive_scheduler => Off => Off
 swoole.unixsock_buffer_size => 262144 => 262144
 swoole.use_shortname => On => On
安装 mcrypt
- 
search pecl search mcryptPackage Stable/(Latest) Local 
 mcrypt 1.0.3 (stable) Bindings for the libmcrypt library
- 
install pecl install mcryptlibmcrypt prefix? [autodetect] : 回车键 Build process completed successfully 
 Installing '/usr/local/Cellar/php@7.3/7.3.16/pecl/20180731/mcrypt.so'
 install ok: channel://pecl.php.net/mcrypt-1.0.3
 Extension mcrypt enabled in php.ini
- 
查看安装 php -i | grep mcryptmcrypt 
 mcrypt support => enabled
 mcrypt_filter support => enabled
 mcrypt.algorithms_dir => no value => no value
 mcrypt.modes_dir => no value => no value
启动和关闭php
- 
查看php版本 
 php -v
- 
启动和关闭PHP 
 brew services start php@7.3
 brew services restart php@7.3
 sudo php-fpm -D
 sudo pkill -9 php-fpm
XDebug性能分析
配置
[xdebug]
; zend_extension="xdebug.so"
; zend_extension="/usr/local/opt/php70-xdebug/xdebug.so"
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host= localhost
xdebug.remote_port = 9001
xdebug.idekey = PHPSTORM
xdebug.trace_format = 0
xdebug.auto_trace = on ;on=开启trace,off=关闭trace
xdebug.auto_profile = on ;打开性能分析
xdebug.collect_params = on
xdebug.collect_return = on
xdebug.profiler_enable = 1 ;1=打开性能分析,0=关闭性能分析
xdebug.profiler_output_dir=/Users/zhoujh/s/logs/xdebug ;性能分析生成的文件目录
xdebug.profiler_output_name=cachegrind.%R
xdebug.trace_output_dir = /Users/zhoujh/s/logs/xdebug
xdebug.trace_output_name = trace.%R
; xdebug.show_exception_trace = On ;开启异常跟踪
xdebug.show_local_vars = 0
; xdebug.dump.GET = *
; xdebug.dump.POST = *
; xdebug.dump.COOKIE = *
; xdebug.dump.SESSION = *
; xdebug.var_display_max_data = 4056
; xdebug.var_display_max_depth = 5