I am trying to get curl to work on my Oracle Linux OS, but I am running into some walls. I am loading my phpinfo() page using an Apache + Django combined server. Furthermore, I have made sure to uncomment the extension=php_curl.dll line in the php.ini file, and I have added the extension=curl.so line. I have also attempted to compile php again using ./configure --with-curl=/usr/include/curl/, followed by the make and sudo make install method calls. However, this recompiling is not reflecting in the phpinfo() page, which still shows a later build date and a different configuration command. As an added note, I am pretty sure I have curl installed. I've run sudo yum install php-curl and sudo yum install curl, and both have responded to me, saying that the php-common and curl packages, respectively, have already been installed.
Does anyone have any advice? Thanks.
I had a similar problem and the solution was to install libcurl & libcurl-devel.
Related
I have to install php5-curl in my OpenWrt. I followed the steps of the official site
When I type, I see available packages:
$ opkg list php5*
but, I don't see php5-culr or php-curl. However, I change the line:
;extension=sockets.so
To:
extension=sockets.so
In php.ini file And also, add a file php_curl.ini in etc/php5/ and restart the server (lighttpd) and nothing happened.
Any help to get CURL in OpenWrt?
I have gnupg and gpgme installed using homebrew.
I also linked both and made sure they are installed and linked by running brew gnupg install and brew gpgme install and got the message confirming the installation and the version.
I have placed the gnupg.so file in the extension path and also added extension=gnupg.so into the php.ini file.
I got the extension path and the specific php.ini's path from the infophp page.
After restarting mamp, I still don't see gnupg or gpgme as extensions on phpinfo, neither I can use gnupg in my php code.
using $gpg = new \gnupg(); this gives me error saying gnupg class doesn't exist.
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'gnupg' not found
I tried another approach:
I also manually downloaded both gnupg and gpgme from their website extracted them ran following
./configure,
make,
sudo make install,
and was able to install successfully again, also made sure that gnupg.so is in the same path that shows up in phpinfo page for extension path and also added extension=gnupg.so to the same php.ini that appears in phpinfo page (I added the extension=gnupg.so right after all the other extensions in the php.ini file)
I am using:
mac os high sierra 10.13.3
php 7.1.12
mamp 4.4.1
gnupg 2.2.5 (I tried this version with brew install)
gnupg 1.4.0 (I tried this version with downloading from gnupg.org)
gpgme 1.10.0
I also would like to know, after hopefully fixing the above mentioned problems, do I need to include anything in my php file in order to use gnupg?
what are the differences between gnupg and gpgme? do I need both in order to encrypt a file in php?
if I wasn't able to fix this what is another way to encrypt xml files or files containing text data? I need to encrypt the file and FTP to another server and decrypt it over there.
Thank you all in advance for your help
I was able to solve this issue using Pecl to install GnuPG.
This link helped me a lot as well.
Run the following in order to install the library:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libgpgme11-dev
sudo pecl install gnupg
Restart your server with: "service apache2 restart", or "sudo service phpX.Y-fpm-sp restart" where x.y is the major.minor version of your php. Note: there are multiple different ways to restart the system so the changes take effect, so please do your own research on how to do it depending on the server and your php version.
As I've explained in my question, try to find the right php.ini file to add the "extension=gnupg.so" into. most common places you'll find your php.ini are:
/etc/php/7.2/apache2 (you can use your PHP version instead of 7.2)
/etc/php/7.2/cli (you can use your PHP version instead of 7.2)
The better way is to find out the php.ini path that loads the extensions, from the phpinfo()
Now Verify that it all went well with the following command:
"php -i | grep -i gnup"
If everything is working as expected you'll see something like this:
/etc/php7.0-sp/conf.d/gnupg.ini,
gnupg
gnupg support => enabled
I've been trying to install mcrypt extension for php5 on Ubuntu 14.04 ARM server running nginx.
PROBLEM
In phpinfo() I can only see the authors of mcrypt but the module itself is missing. I can't use mcrypt functionalities anywhere on that server.
WHAT I TRIED
Running php5 -m shows that mcrypt is installed.
In /etc/php5/fpm/php.ini I have the following extension = /usr/lib/php5/20121212+lfs/mcrypt.so. This I read in google after I tried only with extension = mcrypt.so. Neither gave result.
In /etc/php5/fpm/conf.d/20-mcrypt.ini I have this extension=/usr/lib/php5/20121212+lfs/mcrypt.so as well.
I restarted php5-fpm and nginx multiple times, I also tried php5enmod mcrypt which doesn't show any warnings or errors.
I created symlink between the .so and .ini file.
Any ideas?
Ok so it turns out that my only escape was to purge php5-fpm, reboot the server, then apt-get install php5-fpm, now everything is loaded correctly. I have no idea why this happens. If anyone has explaination I'll be happy to update my answer with it.
I'm trying to set up a cronjob which requires curl, and I'm calling it directly from crontab with
* * * * * /usr/bin/php myurl/my_cron.php
The problem is, it looks like the curl module isn't installed for my phpcli.
It works just fine when I hit the url from my browser, but when I run
php -q myfile.php
from the command line, it returns
PHP Fatal error: Call to undefined function curl_init() in my_cron.php on line 20
When I run php -m the curl module does not show up. However when I go to the browser and dump the php_info(), the module shows up and says its correctly installed.
The other kicker is i've been trying to install curl with apt-get onto the server (Ubuntu 12.04 php 5.4), it seems to take down my PHP as it begins to simply attempt to download the index.php file wherever I try to browse to.
Here are the attempts I've made to install curl that have taken down PHP:
sudo apt-get install php-curl
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
After each of these I restarted the apache2 server and still no dice, it attempted to download the file instead of opening the page.
How can I install php5-curl to just the cli, so that my server can run it and I don't have to go through a browser?
The other possibility is I could run the cronjobs through wget from the crontab file, but I've heard that's not the best option and potentially unreliable.
Any help is much appreciated. Thanks!
I had the same issue. But, finally I solved it by running the following command.
sudo apt-get install php7.0-curl
Restart the server after installing. This answer may not be useful for the user who asked because he asked it two months ago. But, this may be useful for the users who reading this in the future.
Here's how I've fixed this on ubuntu 14.04 when curl was working in php files run through apache, but not when called from the cli.
ssh to your server and cd to /
find / -name 'curl.so'
Run the above find command to locate where the curl binary is hanging out at. If you can't find the file, you might need to install curl and run the find command again.
apt-get install php5-curl
You'll now want to edit the php.ini being used for php files run from the cli (it's different than the one used by apache), and is likely at /etc/php5/cli/php.ini
nano /etc/php5/cli/php.ini
You can also run
php -i | grep 'php.ini'
To get the file path, just to be sure.
In your php.ini file search for [curl] by pressing ctrl + w
You'll now want to add the extension to the file and it should look something like the following, though your path to the curl.so file and such might be a little different:
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo =
extension=/usr/lib/php5/20131226/curl.so
After doing the above, I was able to use curl in php scripts run from the cli.
first find the version of your php cli by:
php -v
for example if it was version 7 then:
sudo apt-cache search php7
this will give you the proper module names for your current version:
php7.0-curl - CURL module for PHP <---- the name of curl module.
php7.0-dev - Files for PHP7.0 module development
php7.0-gd - GD module for PHP
php7.0-gmp - GMP module for PHP
php7.0-json - JSON module for PHP
php7.0-ldap - LDAP module for PHP
php7.0-mysql - MySQL module for PHP
.
.
so on
so to add curl support, copy the name of curl module from the list above then do the following:
sudo apt-get install php7.0-curl
If you are using the command-line interface ('cli') for php5, instead of
php -q myfile.php
please use:
php5 -q myfile.php
php5-curl seems to enable the curl module for the cli php5 and not php and both (can) load different configurations and modules.
I use ubuntu 14.04 and php 5.3. After upgrading to php 5.6.29 I also has problem with php curl. My directory structure after updating to php 5.6.29:
/etc/php5 - old version (5.3)
/etc/php/5.6 - new version
The next command
sudo apt-get install php5-curl
didn't help (looks like it connects to old php version - 5.3).
I have found next article: php 5.6 for magento
It advice to use command
apt-get -y install php5.6-curl
instead of
apt-get -y install php5-curl
It works for me!
The first thing you should always check is your php.ini file. You should have a php.ini file in your web root. Curl is installed by default on most web servers; I haven't found a web server with PHP that hasn't already had curl installed. Its not always enabled, though.
Check your your php.ini file and search for php_curl.dll, it should look like this:
;extension=php_curl.dll
Just remove the semicolon (;) from before "extension" and save the file. It should work right away. According to your phpinfo.php its already installed, so it likely just needs to be enabled.
A similar question can be found here if you're interested: Call to undefined function curl_init()
In case someone reached here to find windows version of running curl.
Open php.ini and remove the ; before extension=php_curl.dll around line 656.
I am pretty much sure what Apache loads is C:\wamp\bin\apache\Apache2.2.17\bin\php.ini therefore you may find curl working from browser.
But when php is run from command line then it may show unknown function curl_init();
Run php -r "echo php_ini_loaded_file();" in the command line to see which ini file is being loaded.
Usually its found inside C:\wamp\bin\php\php5.3.5\php.ini its a different file from what Apache is using. So open it and then remove the ; before extension=php_curl.dll around line 656.
Hope it helps someone.
I am trying to use the new facebook api and it requires libcurl PHP. I used
sudo apt-get install php5-curl
sudo apachectl -k restart
And it didn't work. I get the same error and the phpinfo() page says nothing about libcurl.
The source of this problem is probably that I built some of the tools from source (apache2, php), but then I got bored so installed a lot of the extensions with the package manager. But I'm not exactly how to go about diagnosing the point of failure.
The apt-get install for curl definitely worked, and can be found in
/usr/lib/php5/20060613/curl.so
I think a lot of my confusion stems from not knowing which files go where, and what purpose they have. Any help would be appreciated, and please tell me if I need to provide more information.
edit:
The specific error I get is:
Exception: Facebook needs the CURL PHP extension.
from line
if (!function_exists('curl_init')) {
throw new Exception('Facebook needs the CURL PHP extension.');
}
Ubuntu: 9.10
PHP: 5.2.13
Loaded Configuration File: /etc/php5/apache2/php.ini
In general it's a bad idea to mix and match software from your distribution's package manager with stuff you've built yourself. The package manager will not know anything about the stuff you've built yourself and so can get confused.
Not only that but who's to say the stuff from the package manager is even binary compatible with the stuff you've built yourself? If you build it all yourself then at least you know it will all be compatible.
Sounds to me like you should uninstall the extensions and build them yourself. If you can't or don't want to do that then go back and install apache and friends through your package manager but I would recommend having patience and going for the former option.
Answer of Questions
What version of Ubuntu?
What version of PHP?
How is Apache and PHP set up?
What ini files does phpinfo() say is parsed? (should be near the top)
Perhaps apt failed to properly modify your php.ini file to load the curl extension?
Check out your php.ini and see if you have line like:
extension=curl.so
or maybe:
extension=/usr/lib/php5/20060613/curl.so
To check if php-curl is installed please follow these steps:
Create a file in your web server (in Ubuntu it would be in /var/www folder), name it info.php
Open that file and type this command:
<?php phpinfo(); ?>
Save that file
Open your favorite browser and open that file (ex: http://localhost/info.php)
Now you will see the Information about your PHP installation
Search for Curl, and if you cannot find it, it mean your php doesn’t have curl installed.
To install php-curl please follow these steps:
Open your terminal and type this command:
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt
After it finish open php.ini file (mine is at /etc/php5/apache2/php.ini ) and add this command: extension=curl.so
Save the file and restart apache with this command:
/etc/init.d/apache2 restart
Check the PHP information page again, you will find PHP-CURL installed
That’s it
Source: http://www.ivankristianto.com/os/ubuntu/howto-install-curl-in-php-apache/379/