PHP编译扩展
正式服的PHP环境,一般都会进行编译安装,汇总一下经常遇到的一些问题
1.Call to undefined function crmeb\utils\imagecreate
解决:需要安装gd库
1)进入到源码包ext目录下的gd下 2) phpize(提示如果找不到, 则需要安装autoconf yum install -y autoconf) 3) ./configure --with-php-config=/usr/local/php7/bin/php-config --with-gd 4) make && make install 5) php.ini 文件中添加 extensions=gd.so
2.Call to undefined function crmeb\utils\imagettftext
解决:需要安装freetype
1)wget wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2 2) tar -jxf freetype-2.4.0.tar.bz2 3)cd freetype-2.4.0 4)./configure --prefix=/usr/local/freetype 5) make && make install 6) 来到gd源码包的目录下,重新编译 phpize 7)./configure --with-php-config=/usr/local/php7/bin/php-config --with-freetype-dir=/usr/local/freetype/ 8)make && make install 9)重启php-fpm /etc/init.d/php-fpm restart
3. fileinfo扩展没有安装
安装:
# 1)一般是在源码包下找到该扩展 src/ext/fileinfo # 2) phpize # 3) ./configure --with-php-config=/usr/local/php/bin/php-config 如果提示php-config命令不存在 configure: error: Cannot find php-config. Please use --with-php-config=PATH 可以执行yum install php-devel, 安装php-devel,安装完成之后再执行这条命令即可 # 4)编译并安装 make && make install # 5) 修改php.ini文件,添加extension=fileinfo.so