Solved

Enable cURL in PHP

Posted on 2006-06-19
11
3,268 Views
Last Modified: 2008-02-01
My mandrake linux server running with php apache mysql, all are working fine now. I installed curl rpm succesfully. But curl module is not enabled in php if I look on phpinfo.php. any one help me to enable curl in php. I do see some documents that saying I need to compile PHP with curl.  But PHP is already installed and running fine now. If I compile php will it effect on other applications like Mysql,Postgresql,sendmail etc...Please let me get a solution to enable curl in php.
Thanks in advance.
0
Comment
Question by:tstName
  • 6
  • 5
11 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16934182
Hi tstName,


Do you have a PHP.INI (or equivalent) file? If so look for ;ext=php_curl.dll and remove the ; You may need to restart the web server.

Regards,

Richard Quadling.
0
 

Author Comment

by:tstName
ID: 16939997
Hi Richard Quadling,

The server is a mandrake linux server so I think dll will not play in this.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16940280
Ah. No. But then again. I just realised that you have compiled curl into PHP. I just activate curl by editing the ini file. Sorry. No dufus brain not on.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 40

Accepted Solution

by:
Richard Quadling earned 100 total points
ID: 16940290
Ah. I see the issue.

CURL is an external library/application.

To get CURL accessible from PHP, you need to compile PHP with the library.

From the PHP Manual ...

To use PHP's CURL support you must also compile PHP --with-curl[=DIR] where DIR is the location of the directory containing the lib and include directories. In the "include" directory there should be a folder named "curl" which should contain the easy.h and curl.h files. There should be a file named libcurl.a located in the "lib" directory. Beginning with PHP 4.3.0 you can configure PHP to use CURL for URL streams --with-curlwrappers.




Once you've recompiled PHP to include the CURL library, phpinfo(); should show the module and its state/version.

Compiling PHP will not affect other applications (normally) unless you forget to include a module (--with-xxxx) which is required for comminication.

From what I've seen of PHP on *ix, the phpinfo(); gives your current ./configure line. Use that and then add the CURL options to add CURL to PHP>
0
 

Author Comment

by:tstName
ID: 16940729
Hi  Richard Quadling,

Thanks for the help. can you please tell me what are the steps to recomplie php. I do not need to upgrade php version.
 here the configuration options from phpinfo

'./configure' '--host=i386-redhat-linux' '--build=i386-redhat-linux' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--enable-force-cgi-redirect' '--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-db3'  '--with-dom=/usr' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-ttf' '--with-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml' '--with-expat-dir=/usr' '--with-zlib' '--with-layout=GNU' '--enable-bcmath' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--without-oci8' '--with-pear=/usr/share/pear' '--with-imap=shared' '--with-imap-ssl' '--with-kerberos=/usr/kerberos' '--with-ldap=shared' '--with-mysql=shared,/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-unixODBC=shared' '--enable-memory-limit' '--enable-bcmath' '--enable-shmop' '--enable-versioning' '--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mcal' '--with-apxs2=/usr/sbin/apxs'

thanks
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16940744
Because you want to add a new library to PHP, you need to compile PHP. Unfortunately, I can't help you there as I am on windows.

Though, I believe it is something like

./configure ...
make ...

But I'm not sure.

I would start by reading http://www.php.net/manual/en/install.unix.php and see what you know and don't know.

NOTE : (From the PHP Manual) ...

Prerequisite knowledge and software for compiling:

Basic Unix skills (being able to operate "make" and a C compiler)
An ANSI C compiler
flex: Version 2.5.4
bison: Version 1.28 (preferred), 1.35, or 1.75
A web server
Any module specific components (such as gd, pdf libs, etc.)

0
 

Author Comment

by:tstName
ID: 16950868
I compiled php 4.3.3 with curl ( --with-curl=/usr ) and installed it without any error. but after restart httpd , i dont see any change in the phpinfo. I believe the installation was not success. during the make process I got the warning below,
----
Zend/zend_extensions.lo Zend/zend_hash.lo Zend/zend_list.lo Zend/zend_indent.lo Zend/zend_builtin_functions.lo Zend/zend_sprintf.lo Zend/zend_ini.lo Zend/zend_qsort.lo Zend/zend_multibyte.lo Zend/zend_execute.lo sapi/cli/php_cli.lo sapi/cli/getopt.lo main/internal_functions_cli.lo -lcrypt -lnsl -lcrypt -lintl -lcurl -lz -lssl -lcrypto -lresolv -lm -ldl -lnsl -lcurl -lz -lssl -lcrypto -ldl -lssl -lcrypto -ldl -lz -lcrypt -lcrypt  -o sapi/cli/php
ext/mysql/libmysql/my_tempnam.o(.text+0x40): In function `my_tempnam':
/home/vinod/php-4.3.3/ext/mysql/libmysql/my_tempnam.c:115: the use of `tempnam' is dangerous, better use `mkstemp'
 
Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).  
-------
when I install , i got the messages,
# make install
Installing PHP SAPI module:       cgi
Installing PHP CGI into: /usr/bin/
Installing shared extensions:     /usr/lib/extensions/no-debug-non-zts-20020429/Installing PEAR environment:      /usr/share/pear/
[PEAR] Archive_Tar: Archive_Tar not installed
[PEAR] Console_Getopt: Console_Getopt not installed
requires package `Archive_Tar' >= 0.4
requires package `Console_Getopt' >= 0.11
[PEAR] PEAR: PEAR: Dependencies failed
[PEAR] DB: DB not installed
[PEAR] HTTP           - already installed: 1.2.1
requires package `Net_SMTP' >= 1.1.0
[PEAR] Mail: Mail: Dependencies failed
[PEAR] Net_SMTP: Net_SMTP not installed
[PEAR] Net_Socket: Net_Socket not installed
[PEAR] XML_Parser: XML_Parser not installed
[PEAR] XML_RPC: XML_RPC not installed
Installing build environment:     /usr/lib/php/build/
Installing header files:          /usr/include/php/
 
Installing helper programs:       /usr/bin/
  program: phpize
  program: php-config
  program: phpextdist


after I restart the httpd service, i do not see any changes.
could anyone help me

thanks in advance.

0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16951121
As this is a CGI version, you SHOULD be able to run it from the command line.

Can you try this ...

./php -m

in the appropriate folder.
0
 

Author Comment

by:tstName
ID: 17022298

I do see curl module listed when I use php -m. But libcurl4.so is not updated after make install any idea?
0
 

Author Comment

by:tstName
ID: 17023433
RQuadling,

At last I solved the problem. apxs  was  in wrong place that was the problem to generate libphp4.so. But still I unable to find httpd-devel package for mandrake linux.
Thanks  for your help
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 17030940
NP. Glad to have been just as confused as you!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question