linux php 错误 函数,linux环境解决PHP已安装但忘记支持某些模块导致使用函数报错的问题...

今天在调用php系统函数 easter_date()的过程中,本地没有问题,代码上传到服务器却报了个致命错误:调用未定义的函数 easter_date(),服务器是 Linux 环境。

网上搜了一下,发现问题是因为在安装编译php的过程中没有加–enable-calendar支持。

只能重新编译一下calendar模块了,这个时候我服务器已经编译安装了php,那么如何在增加calendar支持呢?其实很简单,把calendar当做一个扩展来重新编译一下,将生成的文件路径增加到php.ini文件中去即可。

操作步骤:

1. 首先去php官网下载和你当前php环境相同版本的php源码,查看当前php环境的版本可通过 php -v 命令查看。

php源码下载地址:https://www.php.net/downloads.php

2. 下载完毕解压下载到的源码包。

tar -zxvf php-7.2.29.tar.gz

进入编译目录

cd php-7.2.29/ext/calendar/

3. 开始编译安装

/usr/bin/phpize

#若不知道自己的phpize在哪里,可通过whereis phpize命令查找

./configure --with-php-config=/usr/local/php/bin/php-config

#若不知道php-config文件在哪,可通过find / -name 'php-config'查找

make  && make install

以上操作完毕之后会显示出类似下面的提示:

Libraries have been installed in:

/home/yhm/php-7.2.29/ext/calendar/modules

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

- add LIBDIR to the `LD_LIBRARY_PATH' environment variable

during execution

- add LIBDIR to the `LD_RUN_PATH' environment variable

during linking

- use the `-Wl,--rpath -Wl,LIBDIR' linker flag

- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------

Build complete.

Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/

进入php安装目录(每个人的可能不一样)

cd /usr/local/php/etc

vim php.ini

#然后在配置文件里面添加

extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/calendar.so"

然后重启php-fpm就行啦。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值