php5.6.30環境報錯Call to undefined function ImageCreate() 編譯安裝 gd庫

php5.6.30環境報錯Call to undefined function ImageCreate()  編譯安裝 gd庫


發現php5.6.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整個程序

1.下載php5.6.30源碼
php源碼下載站
https://www.php.net/releases/
源碼下載很慢,經過阿里雲國外下載(幾秒鐘),而後傳到國內阿里雲的服務器速度較快
直接國內阿里雲下載也很慢 獲取源碼解壓 # wget https://www.php.net/distributions/php-5.6.30.tar.gz # tar -zxf php-5.6.30.tar.gz # cd php-5.6.30/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-20131226/ 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-20131226/ /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: 2 3 4 5 # Default-Stop: 0 1 6 # 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=0 while test $try -lt 35 ; 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 + 1` sleep 1 done } case "$1" in start) echo -n "Starting php-fpm " $php_fpm_BIN --daemonize $php_opts if [ "$?" != 0 ] ; then echo " failed" exit 1 fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 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 1 fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. Use force-quit" exit 1 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 1 fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop $0 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 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload}" exit 1 ;; esac
相關文章
相關標籤/搜索