33

I have some php scripts that I've been running on an Apache server on a windows machine. These scripts use curl which isn't enabled by default in php. For windows enabling it was as easy and un-commenting the line with the curl .dll file in the php.ini file. Well since Linux uses .so instead of .dll files that wont work.

Does anyone have any idea how to enable curl on an Apache server running on a Linux machine? Php is already installed so I'm really hoping for a solution that doesn't involve re-installing php. Thanks in advance!

Edit: The machine has the openSUSE v11.3 version of linux installed. I'm didn't setup the machine and am interacting with it over command line(putty). Any help would be great.

jcmitch
  • 2,088
  • 9
  • 27
  • 33
  • 1
    Since this is a configuration question it may be better answered on super user or server fault. But also providing more info such as distro and what you have tried will greatly help somebody answer your question. – rhololkeolke Nov 04 '11 at 19:06
  • @user1024157 Check phpinfo(); – Alpha01 Nov 04 '11 at 19:35

6 Answers6

75

If anyone else stumbles onto this page from google like I did:

use putty (putty.exe) to sign into your server and install curl using this command :

    sudo apt-get install php5-curl

Make sure curl is enabled in the php.ini file. For me it's in /etc/php5/apache2/php.ini, if you can't find it, this line might be in /etc/php5/conf.d/curl.ini. Make sure the line :

    extension=curl.so

is not commented out then restart apache, so type this into putty:

    sudo /etc/init.d/apache2 restart

Info for install from https://askubuntu.com/questions/9293/how-do-i-install-curl-in-php5, to check if it works this stack overflow might help you: Detect if cURL works?

Community
  • 1
  • 1
ono2012
  • 4,967
  • 2
  • 33
  • 42
7

I used the previous installation instruction on Ubuntu 12.4, and the php-curl module is successfully installed, (php-curl used in installing WHMCS billing System):
sudo apt-get install php5-curl
sudo /etc/init.d/apache2 restart

By the way the below line is not added to /etc/php5/apache2/php.ini config file as it's already mentioned: extension=curl.so

In addition the CURL module figures in http://localhost/phpinfo.php
Best,

Salim R
  • 343
  • 7
  • 16
5

If it's php 7 on ubuntu, try this

apt-get install php7.0-curl
/etc/init.d/apache2 restart
Frank
  • 1,315
  • 7
  • 24
  • 43
2

if you have used curl above the page and below your html is present and unfortunately your html page is not able to view then just enable your curl. But in order to check CURL is enable or not in php you need to write following code:

echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled';
Martijn
  • 15,791
  • 4
  • 36
  • 68
  • Using this function you will know that your CURL is enable or not.and you can do it by php.ini or through putty server. and after enabling you need to restart apache server – Raghwendra Pathak Oct 17 '14 at 10:26
0

add this line end of php.ini

openssl.cafile=/opt/lampp/share/curl/curl-ca-bundle.crt

may be curl path cannot be identified by PHP

Thamaraiselvam
  • 6,961
  • 8
  • 45
  • 71
  • This answer has been flagged as low quality. If it answers the question, consider adding a bit of text to explain how it works. – lmo Aug 24 '16 at 22:25
0

It dipends on which distribution you are in general but... You have to install the php-curl module and then enable it on php.ini like you did in windows. Once you are done remember to restart apache demon!

andreapier
  • 2,958
  • 2
  • 38
  • 50