记录一次require maatwebsite/excel出现的问题:缺少gd库与zip扩展,然后在已经安装了php-8.0.0后安装扩展库

重新下载php源码包

注:重新去下载php源码包要下载一样版本的,我试过本身是php-8.0.0然后下载php8.0.3的源码包去安装拓展,出现了一系列的报错;

1
2
3
cd /usr/local/src
wget https://www.php.net/distributions/php-8.0.0.tar.gz
tar -zxvf php-8.0.0.tar.gz

gd库

1
2
3
4
5
cd php-8.0.0/ext/gd
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-freetype --with-jpeg
make
make install

然后修改php.ini

1
extension=gd.so

以上为忽略已有freetypejpeglibpng包的情况下
下载目录:
freetype:https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz
jpeg:http://www.ijg.org/files/jpegsrc.v9d.tar.gz
libpng:https://sourceforge.net/projects/libpng/files/
少哪个去安装哪个

1
2
3
4
5
6
wget 下载地址
tar -zxvf 包名
cd 包名
./configure --prefix=安装地址
make
make install

zip扩展

1
2
3
4
5
cd /usr/local/src/php-8.0.0/ext/zip
/usr/local/php/bin/phpize
./configure --with-zip --with-php-config=/usr/local/php/bin/php-config
make
make install

可能会报错:

1
2
3
4
5
6
7
8
9
10
11
checking for libzip >= 0.11... no
configure: error: Package requirements (libzip >= 0.11) were not met:

No package 'libzip' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBZIP_CFLAGS
and LIBZIP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

可能是版本不够或者没有安装
则安装libzip

1
2
3
4
5
6
7
cd /usr/local/src
wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make
make install

安装成功后,在你configure的会话窗口直接输入如下内容:

1
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"

然后重新回去执行zip的./configure
然后修改php.ini

1
extension=zip.so