form1.cn
Make a little progress every day

brew解决macos缺少freetype问题

18th of June 2018 PHP PHPcode 4296

Mac中安装了php的gd库验证码还出不来了,发现提示以下错误:

PHP Fatal error: Call to undefined function imagettfbbox()

因为缺少了freetype,解决方法就是新安装一个php,自带的php忽略


安装一个新的PHP:

brew install php71 --with-apche --with-freetype


或参考:https://blog.csdn.net/liaobangxiang/article/details/79460290


这里的 php71,也可以换成你想要的版本,后边的插件也可以自己随便换,但是一定要有--with-freetype


在安装完成后,会出现一段文字,一定要看一下:

To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/php@7.1/lib/httpd/modules/libphp7.so
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>
Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.1/
This formula is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile
  echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile
For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/php@7.1/lib
    CPPFLAGS: -I/usr/local/opt/php@7.1/include
To have launchd start php@7.1 now and restart at login:
  brew services start php@7.1
Or, if you don't want/need a background service you can just run:
  php-fpm
==> Summary