我从PHP获得了非常奇怪的行为 - 当使用Apache或PHP的内置服务器访问具有简单脚本的网页时:
$c = curl_init();一切都很完美。 但是,当尝试从命令行使用curl_init ,我收到一个错误:“调用未定义的函数curl_init()”
为了纠正这个问题,我尝试使用以下命令重新安装cURL:
sudo apt-get install php5-curl sudo php5enmod curl在此之后我重新启动了我的服务器。 现在cURL甚至没有在Apache工作。
我看了一下/etc/php5/cli/conf.d和/etc/php5/apache2/conf.d ,在每个中我找到了一个带有内容的20-curl.ini的符号链接:
extension=curl.so接下来我检查了php --ini并获得了以下输出:
Configuration File (php.ini) Path: /usr/local/lib Loaded Configuration File: (none) Scan for additional .ini files in: (none) Additional .ini files parsed: (none)我试过find /usr/local/lib -name "php.ini"但它什么都没发现。 这个文件夹中没有php.ini ...为什么它在这里看? 我怎么告诉它看别的地方呢? 为什么它之前有效但现在已经坏了? 为什么apt-get和php5enmod将php.ini放在/ etc / php5而不是/ usr / local / lib中?
我各种各样的困惑:)
I was getting extremely weird behavior from PHP -- when using Apache or PHP's built-in server to access a webpage with a simple script:
$c = curl_init();Everything worked perfectly. However when trying to use curl_init from command-line I got an error: "Call to undefined function curl_init()"
In an attempt to rectify this I tried reinstalling cURL with the following commands:
sudo apt-get install php5-curl sudo php5enmod curlAfter this I restarted my server. Now cURL isn't even working in Apache.
I took a look at /etc/php5/cli/conf.d and /etc/php5/apache2/conf.d and in each of these I found a symlink to 20-curl.ini with the contents:
extension=curl.soNext I checked php --ini and got the following output:
Configuration File (php.ini) Path: /usr/local/lib Loaded Configuration File: (none) Scan for additional .ini files in: (none) Additional .ini files parsed: (none)I tried find /usr/local/lib -name "php.ini" and it found nothing. There is no php.ini in this folder... so why is it looking here? And how do I tell it to look somewhere else? And why did it work before but it's broken now? And why did apt-get and php5enmod put php.ini in /etc/php5 instead of /usr/local/lib?
I'm all sorts of confused :)
最满意答案
因此,如果其他人有类似的问题,请尝试:
find / -name "php"看看你是否安装了两个版本的PHP :)
删除了额外的版本,事情开始表现
So if anyone else has a similar issue, try:
find / -name "php"To see if you have two versions of PHP installed :)
Trashed the extra version and things started behaving
更多推荐
发布评论