最近发现PHP8已正式释出,于是就下来安装试下,按7的方式进行编译安装发现配置不能通过,会报错,如下:
按PHP7的方式编译配置:
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/libxml2/lib/pkgconfig:/usr/local/openssl/lib/pkgconfig:/usr/local/pcre2/lib/pkgconfig:/usr/local/curl/lib/pkgconfig:/usr/local/gd/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/onig/lib/pkgconfig" CFLAGS="-fPIC -O3" LDFLAGS="-Wl,--enable-new-dtags,-rpath=/usr/local/lib:/usr/local/openssl/lib:/usr/local/curl/lib:/usr/local/pcre2/lib:/usr/local/libxml2/lib:/usr/local/gd/lib:/usr/local/lib64" ./configure --prefix=/usr/local/php8 --with-apxs2=/usr/local/apache/bin/apxs --enable-fpm --with-fpm-user=apache --with-fpm-group=apache --with-fpm-systemd --enable-sigchild --enable-libgcc --with-openssl --with-external-pcre --with-pcre-jit --with-zlib --with-bz2=/usr/local/ --enable-calendar --with-curl --enable-gd --with-external-gd --enable-gd-jis-conv --with-gettext --with-mhash=/usr/local/ --with-mysqli=mysqlnd --with-mysql-sock=/data/mariadb/mysql.sock --enable-pdo --with-pdo-mysql=mysqlnd --enable-mysqlnd --with-libedit=/usr/local/ --with-readline=/usr/local/ --with-expat=/usr/local/ --with-iconv-dir=/usr/local/ --with-zip --enable-mbstring=all --enable-bcmath --enable-exif --enable-ftp --enable-opcache --enable-intl --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-inline-optimization --enable-maintainer-zts --enable-zend-signals --with-config-file-path=/usr/local/php8
发现配置不通过出现报错:“configure: error: iconv does not support errno”
经过查找,是由于PHP8的编译配置中去除了几个配置项,而其中就包括iconv,使用自编译的iconv库的话需要在LDFLAGS中明确指定“-liconv”,如下:
那么我使用的最终配置则为:
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/libxml2/lib/pkgconfig:/usr/local/openssl/lib/pkgconfig:/usr/local/pcre2/lib/pkgconfig:/usr/local/curl/lib/pkgconfig:/usr/local/gd/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/onig/lib/pkgconfig" CFLAGS="-fPIC -O3" LDFLAGS="-Wl,--enable-new-dtags,-rpath=/usr/local/lib:/usr/local/openssl/lib:/usr/local/curl/lib:/usr/local/pcre2/lib:/usr/local/libxml2/lib:/usr/local/gd/lib:/usr/local/lib64 -liconv" ./configure --prefix=/usr/local/php8 --with-apxs2=/usr/local/apache/bin/apxs --enable-fpm --with-fpm-user=apache --with-fpm-group=apache --with-fpm-systemd --enable-sigchild --enable-libgcc --with-openssl --with-external-pcre --with-pcre-jit --with-zlib --with-bz2=/usr/local/ --enable-calendar --with-curl --enable-gd --with-external-gd --enable-gd-jis-conv --with-gettext --with-mhash=/usr/local/ --with-mysqli=mysqlnd --with-mysql-sock=/data/mariadb/mysql.sock --enable-pdo --with-pdo-mysql=mysqlnd --enable-mysqlnd --with-libedit=/usr/local/ --with-readline=/usr/local/ --with-expat=/usr/local/ --with-zip --enable-mbstring=all --enable-bcmath --enable-exif --enable-ftp --enable-opcache --enable-intl --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-zts --enable-zend-signals --with-config-file-path=/usr/local/php8
执行通过: