mac 下的php環(huán)境畜吊,要不是自帶編譯好的泽疆,要不就是第三方的庫
類似操作:curl -s http://php-osx.liip.ch/install.sh | bash -s 7.2
第三方庫有個小問題就是重新編譯比較麻煩,例如需要重新添加memcache memcached 等
但是偶爾還需要自行編譯時(例如增加PHP支持GD庫FreeType)操作流程可以參考如下方法:
1玲献、打開本地的phpinfo如下圖示殉疼,得到php的版本號,去下載對應(yīng)的源碼捌年,解包到本地瓢娜;
2、在phpinfo界面的頂部延窜,查看原始編譯命令【configure command】恋腕,復(fù)制出來
WX20190502-092124@2x.png
原始編譯命令(替換掉單引號'之后的字符串)
./configure --prefix=/usr/local/php/7.2 --with-config-file-path=/usr/local/etc/php/7.2 --with-config-file-scan-dir=/usr/local/etc/php/7.2/conf.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir=/usr/local --enable-short-tags --with-zlib --with-libxml-dir=/usr/bin/xml2-config --enable-xml --disable-rpath --enable-bcmath --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt-dir=/usr/local/Cellar/mcrypt/2.6.8/ --with-gd --with-openssl=/usr/local/opt/openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --disable-fileinfo --enable-maintainer-zts --enable-mysqlnd
3、brew install freetype
brew 安裝的位置逆瑞,默認為/usr/local/Cellar/...
然后得到類似路徑: /usr/local/Cellar/freetype/2.9.1/
4荠藤、重新編譯php(其實就是在第二點增加參數(shù) --with-freetype-dir=...)
./configure --prefix=/usr/local/php/7.2 --with-config-file-path=/usr/local/etc/php/7.2 --with-config-file-scan-dir=/usr/local/etc/php/7.2/conf.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir=/usr/local --enable-short-tags --with-zlib --with-libxml-dir=/usr/bin/xml2-config --enable-xml --disable-rpath --enable-bcmath --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt-dir=/usr/local/Cellar/mcrypt/2.6.8/ --with-gd --with-openssl=/usr/local/opt/openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --disable-fileinfo --enable-maintainer-zts --enable-mysqlnd --with-freetype-dir=/usr/local/Cellar/freetype/2.9.1/
5、make clean; make; make install;
6获高、順便在發(fā)一個關(guān)閉php-fpm服務(wù)的命令:
ps -eaf |grep "php-fpm" | grep -v "grep"| awk '{print $2}'|xargs kill -9
完畢