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

本文讲述了在PHP开发中遇到easter_date()函数调用错误的解决方案,涉及编译php时添加calendar模块,详细步骤包括下载源码、配置编译、编译安装并修改php.ini。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在调用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就行啦。

全志R16平台编译linux系统V1.0.txt 2017/4/11 13:36 (编译请使用编译android的lichee的选项编译生成的.config文件,不然直接编译会报错!!!!) rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ tar zxvf lichee_parrotv1.1_20161202.tar.gz rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ cd lichee/ rootroot@cm-System-Product-Name:/home/wwt/linux_r16/lichee$ ./build.sh config Welcome to mkscript setup progress All available chips: 0. sun8iw5p1 Choice: 0 All available platforms: 0. android 1. dragonboard 2. linux 3. tina Choice: 2 All available kernel: 0. linux-3.4 Choice: 0 All available boards: 0. bell-one 1. evb 2. evb-20 3. evb-30 4. evb-rtl8723bs 5. sc3813r Choice: 3 rootroot@cm-System-Product-Name:/home/wwt/linux_r16/lichee$ ./build.sh 错误1: KCONFIG_AUTOCONFIG=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/auto.conf KCONFIG_AUTOHEADER=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/autoconf.h KCONFIG_TRISTATE=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/tristate.config BUILDROOT_CONFIG=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/.config /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/conf --silentoldconfig Config.in # # make dependencies written to .auto.deps # ATTENTION buildroot devels! # See top of this file before playing with this auto-preprequisites! # make[1]:正在离开目录 `/home/wwt/linux_r16/lichee/buildroot' You must install 'makeinfo' on your build machine makeinfo is usually part of the texinfo package in your distribution make: *** [dependencies] 错误 1 make:离开目录“/home/wwt/linux_r16/lichee/buildroot” ERROR: build buildroot Failed rootroot@cm-System-Product-Name:/home/wwt/linux_r16/lichee$ d/buildroot-config/conf.o /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/zconf.tab.o -o /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buil
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值