1、安装本身须要的版本php
- 以php7.1为例,执行:curl -s https://php-osx.liip.ch/install.sh | bash -s 7.1 (去这个连接下找本身想要下载的php版本 https://php-osx.liip.ch/)
- 安装结束后,/usr/local/php5目录下即刚刚install的php
- 此时在终端中输入php -v 显示的仍是老的版本,能够将这个新的PHP路径追加到$path中。
vi ~/.profile 在文件中增长如下一行 export PATH=/usr/local/php5/bin:/usr/local/php5/sbin:$PATH 执行下面的命令使改动当即生效 source ~/.profile
- 此时运行php -v,已是刚刚安装的7.1版本
PHP 7.1.13 (cli) (built: Feb 1 2018 13:38:42) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.13, Copyright (c) 1999-2017, by Zend Technologies with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
- 运行php-fpm -v,查看fpm的版本以下
PHP 7.1.13 (fpm-fcgi) (built: Feb 1 2018 13:38:47) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.13, Copyright (c) 1999-2017, by Zend Technologies with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
- php.ini在/usr/local/php5/lib/php.ini
- 扩展的一些配置都在/usr/local/php5/php.d/目录下,能够看到xdebug扩展已经安装了。
-rw-r--r-- 1 root wheel 75 2 1 20:41 10-extension_dir.ini -rw-r--r-- 1 root wheel 53 2 1 20:41 20-extension-opcache.ini -rw-r--r-- 1 root wheel 41 2 1 20:41 40-curl.ini -rw-r--r-- 1 root wheel 44 2 1 20:41 40-openssl.ini -rw-r--r-- 1 root wheel 103 2 1 20:41 50-extension-apcu.ini -rw-r--r-- 1 root wheel 18 2 1 20:41 50-extension-curl.ini -rw-r--r-- 1 root wheel 17 2 1 20:41 50-extension-gmp.ini -rw-r--r-- 1 root wheel 83 2 1 20:41 50-extension-igbinary.ini -rw-r--r-- 1 root wheel 18 2 1 20:41 50-extension-imap.ini -rw-r--r-- 1 root wheel 79 2 1 20:41 50-extension-intl.ini -rw-r--r-- 1 root wheel 20 2 1 20:41 50-extension-mcrypt.ini -rw-r--r-- 1 root wheel 84 2 1 20:41 50-extension-memcached.ini -rw-r--r-- 1 root wheel 82 2 1 20:41 50-extension-mongodb.ini -rw-r--r-- 1 root wheel 22 2 1 20:41 50-extension-mssql.ini -rw-r--r-- 1 root wheel 23 2 1 20:41 50-extension-pdo_pgsql.ini -rw-r--r-- 1 root wheel 19 2 1 20:41 50-extension-pgsql.ini -rw-r--r-- 1 root wheel 81 2 1 20:41 50-extension-propro.ini -rw-r--r-- 1 root wheel 80 2 1 20:41 50-extension-raphf.ini -rw-r--r-- 1 root wheel 22 2 1 20:41 50-extension-readline.ini -rw-r--r-- 1 root wheel 80 2 1 20:41 50-extension-redis.ini -rw-r--r-- 1 root wheel 79 2 1 20:41 50-extension-solr.ini -rw-r--r-- 1 root wheel 79 2 1 20:41 50-extension-ssh2.ini -rw-r--r-- 1 root wheel 427 5 8 17:20 50-extension-xdebug.ini -rw-r--r-- 1 root wheel 17 2 1 20:41 50-extension-xsl.ini -rw-r--r-- 1 root wheel 79 2 1 20:41 60-extension-pecl_http.ini -rw-r--r-- 1 root wheel 2004 2 1 20:41 99-liip-developer.ini
- 已经安装编译的扩展镜像在/usr/local/php5/lib/php/extensions/no-debug-non-zts-20160303/下
-rwxr-xr-x 1 root wheel 71936 2 1 20:41 apcu.so -rwxr-xr-x 1 root wheel 78668 2 1 20:41 curl.so -rwxr-xr-x 1 root wheel 44108 2 1 20:41 gmp.so -rwxr-xr-x 1 root wheel 350380 2 1 20:41 http.so -rwxr-xr-x 1 root wheel 42828 2 1 20:41 igbinary.so -rwxr-xr-x 1 root wheel 3188820 2 1 20:41 imap.so -rwxr-xr-x 1 root wheel 510600 2 1 20:41 intl.so -rwxr-xr-x 1 root wheel 38652 2 1 20:41 mcrypt.so -rwxr-xr-x 1 root wheel 84892 2 1 20:41 memcached.so -rwxr-xr-x 1 root wheel 2807892 2 1 20:41 mongodb.so -rwxr-xr-x 1 root wheel 322864 2 1 20:41 opcache.so -rwxr-xr-x 1 root wheel 38228 2 1 20:41 pdo_pgsql.so -rwxr-xr-x 1 root wheel 108104 2 1 20:41 pgsql.so -rwxr-xr-x 1 root wheel 16540 2 1 20:41 propro.so -rwxr-xr-x 1 root wheel 18064 2 1 20:41 raphf.so -rwxr-xr-x 1 root wheel 28824 2 1 20:41 readline.so -rwxr-xr-x 1 root wheel 331964 2 1 20:41 redis.so -rwxr-xr-x 1 root wheel 232832 2 1 20:41 solr.so -rwxr-xr-x 1 root wheel 63252 2 1 20:41 ssh2.so -rwxr-xr-x 1 root wheel 213268 2 1 20:41 xdebug.so -rwxr-xr-x 1 root wheel 30160 2 1 20:41 xsl.so
2、安装nginx
- 利用brew神器,brew install nginx
- 安装完毕后,nginx的相关配置在/usr/local/etc/nginx/目录下,没有nginx.conf的话,将nginx.conf.default拷贝一份命名为nginx.conf
- 若是80端口冲突的话能够把mac自带的apache2的httpd进程杀死,或者在nginx.conf的server部分监听一个非80端口,好比8080等。
- /usr/local/etc/nginx/servers/目录下是各个域名单独的配置。
3、安装mysql、mongodb
mysql和mongodb均可以使用brew来安装。php
4、Xdebug配置
- 前面已经安装好了Xdebug扩展
- 配置php.ini,增长如下几行,zend_extension填xdebug扩展镜像路径,端口要和phpstorm里配置的一致,能够填9001。
[xdebug] zend_extension =/usr/local/php5/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so xdebug.remote_enable = On xdebug.remote_handler = "dbgp" xdebug.remote_host = "localhost" xdebug.remote_port = 9001 xdebug.idekey = PHPSTROM
- 执行ps aux | grep php-fpm,找到php-fpm的进程号
root 29992 0.0 0.0 4394508 680 ?? Ss 5:20下午 0:00.61 /usr/local/php5/sbin/php-fpm clive 32520 0.0 0.0 4286184 900 s002 S+ 7:57下午 0:00.00 grep php-fpm nobody 31455 0.0 0.0 4402220 3408 ?? S 6:43下午 0:00.55 /usr/local/php5/sbin/php-fpm nobody 31431 0.0 0.0 4408428 3468 ?? S 6:43下午 0:02.31 /usr/local/php5/sbin/php-fpm nobody 31428 0.0 0.0 4408428 3428 ?? S 6:43下午 0:02.43 /usr/local/php5/sbin/php-fpm
- 执行命令杀死php-fpm进程,sudo kill -9 29992 31455 31431 31428
5、配置PHPStorm的Xdebug工具
- 打开phpstorm,选择preferences,找到php下的Debug,配置以下:
- preferences下找到php下的servers,配置以下:
- preferences下找到php下的Debug下的DBGp Proxy,配置以下:
- 增长web debug配置:
- 配置完毕!打上断点进行愉快的debug吧~