php5..30环境报错Call to undefined function ImageCreate() 编译安装 gd库 发现php5..30没有加载gd库 [root@cn_vs_web04:/usr/local/php]# php -i |grep configure
Configure Command => './configure' '--prefix=/usr/local/php-5.6.30_fpm' '--with-openssl=/usr/local/lab/openssl' '--with-libxml-dir=/usr' '--with-zlib-dir=/usr/local/lab/zlib-1.2.8' '--with-bz2' '--enable-calendar' '--with-curl=/usr/local/lab/curl-7.36.0' '--enable-dba' '--enable-exif' '--enable-ftp' '--with-jpeg-dir=/usr/local/lab/libjpeg-6b' '--with-png-dir=/usr/local/lab/libpng-1.6.10' '--with-freetype-dir=/usr/local/lab/freetype-2.5.4' '--with-gettext' '--enable-mbstring' '--with-ldap=/usr/local/openldap-2.4.23' '--with-mcrypt=/usr/local/lab/libmcrypt-2.5.8' '--with-mhash=/usr/local/lab/mhash-0.9.9.9' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-unixODBC=/usr/local/lab/unixODBC-2.3.2' '--with-pdo-dblib=/usr/local/lab/freetds-0.92' '--enable-zip' '--with-iconv-dir=/usr/local/lab/libiconv-1.14' '--with-fpm-user=apache' '--with-fpm-group=users' '--enable-fpm' '--with-xmlrpc' '--enable-soap' '--enable-mbregex' '--enable-opcache' '--enable-inline-optimization' '--enable-xml' '--enable-sockets' '--disable-debug 解决办法: 编译的时候没有把gd库编译进去,需要再次加进去,还好gd库是扩展库,不需要重新编译php整个程序 .下载php5..30源码
php源码下载站
https://www.php.net/releases/
源码下载很慢,通过阿里云国外下载(几秒钟),然后传到国内阿里云的服务器速度较快
直接国内阿里云下载也很慢 获取源码解压
# wget https://www.php.net/distributions/php-5.6.30.tar.gz
# tar -zxf php-5.6..tar.gz
# cd php-5.6./ext/gd 在源码目录执行phpize
# /usr/local/php/bin/phpize # 重新编译
# ./configure --with-php-config=/usr/local/php/bin/php-config --with-gd
# make && make install Build complete.
Don't forget to run 'make test'. Installing shared extensions: /usr/local/php-5.6.30_fpm/lib/php/extensions/no-debug-non-zts-/
Installing header files: /usr/local/php-5.6.30_fpm/include/php/ # 将扩展库加入到扩展库文件夹中 cp /usr/local/php-5.6.30_fpm/lib/php/extensions/no-debug-non-zts-/ /usr/local/php/lib/php/extensions 编辑php.ini加入gd.so扩展库 # vim /usr/local/php/php.ini
extension_dir=/usr/local/php/lib/php/extensions
extension=gd.so # 重新启动php
/etc/init.d/php-fpm restart # 验证
[root@cn_vs_web04:/usr/local/lab]# php -m|grep gd
gd [root@cn_vs_web04:/usr/local/lab]# cat /etc/init.d/php-fpm
#! /bin/sh ### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start:
# Default-Stop:
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
### END INIT INFO prefix=/usr/local/php
exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=${prefix}/var/run/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID" wait_for_pid () {
try= while test $try -lt ; do case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;; 'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac echo -n .
try=`expr $try + `
sleep done } case "$1" in
start)
echo -n "Starting php-fpm " $php_fpm_BIN --daemonize $php_opts if [ "$?" != ] ; then
echo " failed"
exit
fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then
echo " failed"
exit
else
echo " done"
fi
;; stop)
echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit
fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then
echo " failed. Use force-quit"
exit
else
echo " done"
fi
;; force-quit)
echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit
fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then
echo " failed"
exit
else
echo " done"
fi
;; restart)
$ stop
$ start
;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit
fi kill -USR2 `cat $php_fpm_PID` echo " done"
;; *)
echo "Usage: $0 {start|stop|force-quit|restart|reload}"
exit
;; esac
这个事情还有后续,发现gd库缺少freetype支持,导致部分验证码功能失效,需要重新编译带freetype参数的
cd /usr/local/src/php-5.6.30/ext/gd
make clean
/usr/local/php/bin/phpize
# 编译带freetype支持的gd库,如果没有freetype组件需要手动编译安装
./configure --with-php-config=/usr/local/php/bin/php-config --with-gd --with-freetype-dir=/usr/local/lab/freetype-2.5.4
make && make install
# 替换现有的gd.so文件
cp /usr/local/php-5.6.30_fpm/lib/php/extensions/no-debug-non-zts-20131226/gd.so /usr/local/php/lib/php/extensions