PHP 7.4 checking for libzip 和 failed to open error_log 问题

两个深坑,成年阿根廷龙踩出来的坑,网上都没找到解决方法,都是自己摸索出来的。

前面一切顺利:

yum install -y libxml2 libxml2-devel libxml2-python curl curl-devel libjpeg libjpeg-devel libpng  libpng-devel freetype-devel libmcrypt libmcrypt-devel gd gd-devel gcc-c++ gcc openssl openssl-devel  libsqlite3x-devel oniguruma-devel libicu-devel

wget https://www.php.net/distributions/php-7.4.2.tar.gz
tar xf php-7.4.2.tar.gz 
cd php-7.4.2
./configure --prefix=/usr/local/php --enable-opcache --with-config-file-path=/usr/local/php/etc --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-fpm --enable-static --enable-inline-optimization --enable-sockets  --with-zip --enable-calendar --enable-bcmath --enable-soap --enable-mbstring --with-zlib --with-iconv --enable-gd --with-xmlrpc --enable-mbstring --with-curl --with-freetype --with-mysql-sock=/var/lib/mysql/mysql.sock   --disable-ipv6 --disable-debug --with-openssl --disable-maintainer-zts --enable-intl

至于configure的时候,配置参数的变更、弃用等这种小问题就不说了。

No package 'libzip' found

我不知道网上的教程是怎么回事,反正在centos7+PHP 7.4.2 环境下,网上的所有教程都不对,一个都不对
这个问题的完整报错如下:

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库,你用yum安装libzip-devel的话,安装的版本是0.10,版本达不到要求。所以,此时我们需要卸载掉yum安装的libzip然后手动安装新版。

yum remove libzip libzip-devel
wget https://hqidi.com/big/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install

在网上找到的教程到了这一步就直接让你继续在PHP源码目录里面执行configure程序继续配置了,其实你虽然已经安装了libzip1.2,但是PHP的configure程序依然找不到,不知道你安装在哪,你得告诉PHP的configure程序,我安装了libzip 1.2,并且安装在何处。以前是用ldconfig来通告系统所需动态库文件的位置,现在用pkg-config。
我刚刚提供的方法安装的libzip默认被安装到了 /usr/local/lib 在这个目录下你能看到libzip.so libzip.so.5 libzip.so.5.0.0 还有一个pkgconfig目录。
所以,真正的解决方法来了,在你configure的会话窗口直接输入如下内容:
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
上面命令的作用就是告诉configure程序,去/usr/local/lib 目录下找库文件,这样他就能找到libzip.so
此时,你继续./configure将会很顺利的看到
Thank you for using PHP.

PHP7报错Read-only file system (30)

当你照着 此文 安装好PHP,并做好systemd服务管理文件,你会发现用systemctl start php-fpm 无法正常启动php-fpm 报了一个很奇怪的错。
ERROR: failed to open error_log (/usr/local/php/var/log/php-fpm.log): Read-only file system (30)
此时,selinux是关闭状态,普通用户对这个文件也可写,问题就迷离了。
解决方法:
打开 /usr/lib/systemd/system/php-fpm.service 把
ProtectSystem=true
改成
ProtectSystem=false

当这个值为true的时候,php-fpm进程将以只读的方式挂载 /usr 目录,这就是问题所在。具体可参考
https://www.freedesktop.org/software/systemd/man/systemd.exec.html#ProtectSystem=

原创文章,转载请注明: 转载自笛声

本文链接地址: PHP 7.4 checking for libzip 和 failed to open error_log 问题

14 条评论

  • 姜辰 2020年2月16日 回复

    emm我以后踩坑了就来找你。哈哈

  • 西枫里博客 2020年2月16日 回复

    宝塔用户,直接忽略你这一大篇文章。。。。

  • 石樱灯笼 2020年3月3日 回复

    之前尝试用apt安装php7.4,也报了找不到 libzip 的错误。
    没必要的话我还是不在旧环境上更新了。

  • 吴杰的博客 2020年3月3日 回复

    谢谢,我之前也是libzip的问题编译了不起作用,所以偷懒使用第三方源编译好的。前几个版本一直没问题,到7.4.3就编译不过了,使用你的方法,通过pkg-config成功了。我可以在我博客部分引用你的文章吗?注明了来源了。懒得再重复写一次了。?

    • dige 2020年3月4日 回复 作者

      可以的,欢迎。

  • 博客PHP版本升级到7.4.3 – 吴杰的博客 2020年3月4日 回复

    […] https://hqidi.com/154.html […]

  • zxc 2020年3月26日 回复

    PHP7报错Read-only file system (30),参考后解决了,谢谢

  • ERROR: failed to open error_log (/usr/local/var/log/php-fpm.log): Read-only file system (30) | 杨龙 2020年5月28日 回复

    […] https://hqidi.com/154.html […]

  • 在centos7上PHP 7.4.7编译安装遇见的问题 | 老廖啊啊啊 2020年6月21日 回复

    […] 参考文章来源:https://hqidi.com/154.html […]

  • zhang goyeee 2020年8月2日 回复

    非常感谢。

  • PHP7报错Read-only file system (30) – 郭仁旭的博客 2020年8月9日 回复

    […] 转载自https://hqidi.com/154.html […]

  • Zhangz 2020年9月26日 回复

    大哥 你救了我的命

  • zhoucx 2020年10月15日 回复

    大哥,Read-only file system困扰了我一下午,终于在下班前看到了你的文章,太感谢了

    • dige 2020年10月16日 回复 作者

      能帮到你就好。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Copyright © 2015-2024 笛声博客 All Rights Reserved     浙ICP备15036123号-1