二丫讲梵 二丫讲梵
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)

二丫讲梵

行者常至,为者常成
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)
  • 最佳实践

  • 迎刃而解

  • Nginx

  • Php

    • 给php-7-1-5添加扩展fileinfo
    • CentOS7源码部署PHP-7-0-27
    • PHP添加各种模块
    • PHP项目chroot相关内容
    • PHP新增sodium模块
    • 添加swoole扩展的一个报错处理
    • 使用yum-remi部署PHP及其依赖
    • PHP7-4总是无法读取系统环境变量
    • PHP项目发布时执行reload会有502的问题
  • Zabbix

  • AWS

  • Prometheus

  • Grafana

  • Loki

  • CentOS

  • Supervisord

  • Systemd

  • Docker

  • Docker-Compose

  • Rancher

  • Ansible

  • OpenLdap

  • GitLab

  • GitHub

  • Etcd

  • Consul

  • RabbitMQ

  • Kafka

  • Mysql

  • MongoDB

  • OpenVPN

  • Kvm

  • VMware

  • 配置文件详解

  • Other

  • 运维观止
  • Php
二丫讲梵
2019-05-04

给php-7-1-5添加扩展fileinfo

文章发布较早,内容可能过时,阅读注意甄别。

fileinfo 这个扩展是 php 自带的,但是使用 lnmp 一键安装脚本部署的时候并没有启用这个扩展,今天想要部署一个图床服务需要安装这个扩展。

在网上看了不少的文章,基本上都没有效果。这里记录下。

先来看一下是什么状态:

[root@eryajf ~]$php -i |grep fileinfo
Configure Command =>  './configure'  '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--with-config-file-scan-dir=/usr/local/php/conf.d' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--enable-mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir=/usr/local/freetype' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--enable-mbregex' '--enable-mbstring' '--enable-intl' '--with-mcrypt' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-opcache' '--with-xsl'
fileinfo
fileinfo support => enabled
1
2
3
4

然后去到源码目录进行重新编译添加:

[root@eryajf ~]$cd /mnt/lnmp1.4-full/src/php-7.1.5/ext/fileinfo/
1

这时这个目录是无法直接编译的,需要执行以下命令生成编译文件:

[root@eryajf fileinfo]$phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
1
2
3
4
5

然后进行编译即可:

./configure --with-php-config=/usr/local/php/bin/php-config --enable-fileinfo
make && make install
1
2

如果执行无误,则会在最后输出一个目录。

[root@eryajf min-wiki]$ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303
fileinfo.so  opcache.a  opcache.so
1
2

可以看到这里已经生成了需要的 so 文件。

申明

原创文章eryajf,未经授权,严禁转载,侵权必究!此乃文中随机水印,敬请读者谅解。

Copyright 二丫讲梵 (opens new window) 版权所有

接着配置php.ini进行引用:

extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/fileinfo.so"
1

将如上内容添加在文件当中。然后重启即可。

image

不过在重启的时候可能会遇到下边的报错:

NOTICE: PHP message: PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) ‘fileinfo.so’ in Unknown on line 0
1

解决办法是回到上边添加一条命令:

$ rm -rf /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/fileinfo.so
$ make clean
$ ./configure --with-php-config=/usr/local/php/bin/php-config --enable-fileinfo
$ make && make install
1
2
3
4

然后再重启就能够看到添加成功了。

[root@eryajf fileinfo]$php -m |grep fileinfo
fileinfo
1
2
微信 支付宝
#php
上次更新: 2024/07/04, 22:40:37
从Nginx过滤打印user-agent为clb-healthcheck的日志聊聊Nginx的日志自定义打印
CentOS7源码部署PHP-7-0-27

← 从Nginx过滤打印user-agent为clb-healthcheck的日志聊聊Nginx的日志自定义打印 CentOS7源码部署PHP-7-0-27→

最近更新
01
记录二五年五一之短暂回归家庭
05-09
02
学习周刊-总第210期-2025年第19周
05-09
03
学习周刊-总第209期-2025年第18周
05-03
更多文章>
Theme by Vdoing | Copyright © 2017-2025 | 点击查看十年之约 | 浙ICP备18057030号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式