php5.6.30环境报错Call to undefined function ImageCreate() 编译安装 gd库
生活随笔
收集整理的這篇文章主要介紹了
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 installBuild 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 INFOprefix=/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.pidphp_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"wait_for_pid () {try=0while test $try -lt 35 ; docase "$1" in'created')if [ -f "$2" ] ; thentry=''breakfi;;'removed')if [ ! -f "$2" ] ; thentry=''breakfi;;esacecho -n .try=`expr $try + 1`sleep 1done}case "$1" instart)echo -n "Starting php-fpm "$php_fpm_BIN --daemonize $php_optsif [ "$?" != 0 ] ; thenecho " failed"exit 1fiwait_for_pid created $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed"exit 1elseecho " done"fi;;stop)echo -n "Gracefully shutting down php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -QUIT `cat $php_fpm_PID`wait_for_pid removed $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed. Use force-quit"exit 1elseecho " done"fi;;force-quit)echo -n "Terminating php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -TERM `cat $php_fpm_PID`wait_for_pid removed $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed"exit 1elseecho " done"fi;;restart)$0 stop$0 start;;reload)echo -n "Reload service php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -USR2 `cat $php_fpm_PID`echo " done";;*)echo "Usage: $0 {start|stop|force-quit|restart|reload}"exit 1;;esac
源碼下載很慢,通過阿里云國外下載(幾秒鐘),然后傳到國內阿里云的服務器速度較快
直接國內阿里云下載也很慢 獲取源碼解壓 # 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 installBuild 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 INFOprefix=/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.pidphp_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"wait_for_pid () {try=0while test $try -lt 35 ; docase "$1" in'created')if [ -f "$2" ] ; thentry=''breakfi;;'removed')if [ ! -f "$2" ] ; thentry=''breakfi;;esacecho -n .try=`expr $try + 1`sleep 1done}case "$1" instart)echo -n "Starting php-fpm "$php_fpm_BIN --daemonize $php_optsif [ "$?" != 0 ] ; thenecho " failed"exit 1fiwait_for_pid created $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed"exit 1elseecho " done"fi;;stop)echo -n "Gracefully shutting down php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -QUIT `cat $php_fpm_PID`wait_for_pid removed $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed. Use force-quit"exit 1elseecho " done"fi;;force-quit)echo -n "Terminating php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -TERM `cat $php_fpm_PID`wait_for_pid removed $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed"exit 1elseecho " done"fi;;restart)$0 stop$0 start;;reload)echo -n "Reload service php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -USR2 `cat $php_fpm_PID`echo " done";;*)echo "Usage: $0 {start|stop|force-quit|restart|reload}"exit 1;;esac
?
轉載于:https://www.cnblogs.com/reblue520/p/10950990.html
總結
以上是生活随笔為你收集整理的php5.6.30环境报错Call to undefined function ImageCreate() 编译安装 gd库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux文本处理三剑客之sed
- 下一篇: Dockerfile构建PHP镜像