Solved

Adding cURL support on Linux box

Posted on 2004-10-04
16
1,434 Views
Last Modified: 2013-12-13
Hello:

I have run in to a situation where I need to add cURL support to PHP on my RH 6.2 box. I have the rpms installed but I beleive I need to recompile PHP now.

1) Is this correct?

2) How do I do it?

3) How do I do it in such a way that I retain all previous settings that were in place?

4) Is there a way to back it up?

Thanks
Rob
0
Comment
Question by:RobMarreel
  • 8
  • 8
16 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 12221434
Which php-version are you using (sorry, no RH 6.2 available). The following should work with php 4.3.x (maybe also on sooner version), but for further help your php-version might be improtant so I can have a look at the sources.

You don't need to recompile your php. You can also manage to create the curl as a loadable-module for you php.version.
To do that, install the php-sources of the php-version you are using and change into the unpacked sources. Then do:

cd ext/curl
phpize
./configure --with-curl=shared
make
make install

edit you php.ini to enable the new extension for php:
extension=curl.so

make sure you also have install curl-dev and mod_php4-dev or php-dev -rpms.
0
 

Author Comment

by:RobMarreel
ID: 12244463
Looks like I have PHP 4.1.2 installed. Where am I going to get the sources for that one? Seems like its kind of old.

Maybe it is already on this linux box. Is there a way to check ?

Thanks
Rob
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12245925
You can download php 4.1.2 from here:
http://www.php.net/releases.php

Search for a file called TODO-4.2.txt, which should be in the 4.1.2 -source directory
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:RobMarreel
ID: 12256113
OK. I did everything that you listed but it still can't find curl_init(). Do I need to include something or take another step? I even restarted httpd.

Thanks
Rob
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12256279
Yes, you need to enable the extension in your php.ini

extension=curl.so

and restart/reload your webserver

or use that code in your php-script:
if (!extension_loaded('curl')) {
    dl('curl.so');
}
0
 

Author Comment

by:RobMarreel
ID: 12260973
I took a closer look at the ouput and I am getting this:

*** Warning: This library needs some functionality provided by -lcurl.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

*** Warning: This library needs some functionality provided by -lcrypto.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

*** Warning: This library needs some functionality provided by -lssl.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

*** Warning: This library needs some functionality provided by -lcurl.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

*** Warning: libtool could not satisfy all declared inter-library
*** dependencies of module curl.  Therefore, libtool will create
*** a static module, that should work as long as the dlopening
*** application is linked with the -dlopen flag.


I beleive I have everything installed that you suggested. Come to find out only the curl.a and curl.la files are being built, not the so.

Rob
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12261984
The curl.so should be in the .libs-directory (hidden) ext/curl/.libs
0
 

Author Comment

by:RobMarreel
ID: 12263513
curl.so isn't there. It isn't anywhere on the HD actually I did a search. I would think it could still compile with the warnings above, but does that make a difference?

in that folder I have:

curl.a
curl.la (link to ../curl.la)
curl.lai

Thanks for the help.

Rob
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12263576
did the make run till the end without errors ?? If so the curl.so from the .libs directory may work.
0
 

Author Comment

by:RobMarreel
ID: 12264131
Here is the output for all of the commands you told me to run. Looks ok to me.



aclocal: macro `AC_ADD_LIBPATH' defined in acinclude.m4 but never used
aclocal: macro `AC_ADD_LIBRARY' defined in acinclude.m4 but never used
aclocal: macro `AC_ADD_LIBRARY_WITH_PATH' defined in acinclude.m4 but never used
aclocal: macro `AC_ADD_INCLUDE' defined in acinclude.m4 but never used



loading cache ./config.cache
checking for gcc... (cached) gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking whether gcc and cc understand -c and -o together... (cached) yes
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20010901
checking for CURL support... yes, shared
checking for CURL in default path... found in /usr
checking for cURL greater than 7.8.1... libcurl 7.9.8
checking for curl_easy_perform in -lcurl... (cached) yes
checking host system type... i686-pc-linux-gnu
checking build system type... i686-pc-linux-gnu
checking for ranlib... (cached) ranlib
checking for ld used by GCC... (cached) /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... (cached) yes
checking for BSD-compatible nm... (cached) /usr/bin/nm -B
checking whether ln -s works... (cached) yes
checking for object suffix... o
checking for executable suffix... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.lo... yes
checking if gcc supports -fno-rtti -fno-exceptions ... yes
checking if gcc static flag -static works... -static
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the linker (/usr/bin/ld) supports shared libraries... yes
checking command to parse /usr/bin/nm -B output... ok
checking how to hardcode library paths into programs... immediate
checking for /usr/bin/ld option to reload object files... -r
checking dynamic linker characteristics... Linux ld.so
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for objdir... .libs
creating libtool
loading cache ./config.cache
checking for working mkdir -p... (cached) yes
creating config_vars.mk
creating Makefile
creating ./config.status
creating config.h
config.h is unchanged


make[1]: Entering directory `/usr/tmpdir/php-4.1.2/ext/curl'
make[1]: Nothing to be done for `all-p'.
make[1]: Leaving directory `/usr/tmpdir/php-4.1.2/ext/curl'
[root@marreel curl]# make clean
make[1]: Entering directory `/usr/tmpdir/php-4.1.2/ext/curl'
make[1]: Nothing to be done for `clean-p'.
make[1]: Leaving directory `/usr/tmpdir/php-4.1.2/ext/curl'
rm -f curl.la *.lo *.slo *.la *.o
rm -rf .libs
[root@marreel curl]# make
make[1]: Entering directory `/usr/tmpdir/php-4.1.2/ext/curl'
/bin/sh /usr/tmpdir/php-4.1.2/ext/curl/libtool --mode=compile gcc -I. -I/usr/tmpdir/php-4.1.2/ext/curl/ -I/usr/tmpdir/php-4.1.2/ext/curl/main -I/usr/tmpdir/php-4.1.2/ext/curl -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM  -DHAVE_CONFIG_H  -prefer-pic  -c curl.c && touch curl.slo
gcc -I. -I/usr/tmpdir/php-4.1.2/ext/curl/ -I/usr/tmpdir/php-4.1.2/ext/curl/main -I/usr/tmpdir/php-4.1.2/ext/curl -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM -DHAVE_CONFIG_H -prefer-pic -c curl.c  -fPIC -DPIC -o curl.lo
gcc: unrecognized option `-prefer-pic'
/bin/sh /usr/tmpdir/php-4.1.2/ext/curl/libtool --mode=link gcc  -I. -I/usr/tmpdir/php-4.1.2/ext/curl/ -I/usr/tmpdir/php-4.1.2/ext/curl/main -I/usr/tmpdir/php-4.1.2/ext/curl -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM  -DHAVE_CONFIG_H -g -O2   -o curl.la -avoid-version -module -rpath /usr/tmpdir/php-4.1.2/ext/curl/modules  curl.lo  -lcurl -ldl -lcrypto -lssl -lcurl
mkdir .libs

*** Warning: This library needs some functionality provided by -lcurl.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

*** Warning: This library needs some functionality provided by -lcrypto.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

*** Warning: This library needs some functionality provided by -lssl.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

*** Warning: This library needs some functionality provided by -lcurl.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

*** Warning: libtool could not satisfy all declared inter-library
*** dependencies of module curl.  Therefore, libtool will create
*** a static module, that should work as long as the dlopening
*** application is linked with the -dlopen flag.
ar cru .libs/curl.a curl.lo
ranlib .libs/curl.a
creating curl.la
(cd .libs && rm -f curl.la && ln -s ../curl.la curl.la)
/bin/sh /usr/tmpdir/php-4.1.2/ext/curl/libtool --mode=install cp curl.la /usr/tmpdir/php-4.1.2/ext/curl/modules
cp .libs/curl.lai /usr/tmpdir/php-4.1.2/ext/curl/modules/curl.la
cp .libs/curl.a /usr/tmpdir/php-4.1.2/ext/curl/modules/curl.a
ranlib /usr/tmpdir/php-4.1.2/ext/curl/modules/curl.a
chmod 644 /usr/tmpdir/php-4.1.2/ext/curl/modules/curl.a
PATH="$PATH:/sbin" ldconfig -n /usr/tmpdir/php-4.1.2/ext/curl/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/tmpdir/php-4.1.2/ext/curl/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 `-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.
----------------------------------------------------------------------
make[1]: Leaving directory `/usr/tmpdir/php-4.1.2/ext/curl'


make[1]: Entering directory `/usr/tmpdir/php-4.1.2/ext/curl'
installing shared modules into /usr/local/lib/php/extensions/no-debug-non-zts-20010901
make[1]: Leaving directory `/usr/tmpdir/php-4.1.2/ext/curl'

0
 
LVL 48

Expert Comment

by:hernst42
ID: 12265468
Which file are located in /usr/local/lib/php/extensions/no-debug-non-zts-20010901 ?

try this short php-code:

<?php
dl('curl.la');
$c = curl_init('http://www.example.com');

to see if that lib loads instead of the curl.so
0
 

Author Comment

by:RobMarreel
ID: 12266533
The only file located in that dir is curl.a

So I tried your code but changed it to curl.a. I also tried moving curl.a up one folder to the extensions dir. Says it can't find the file curl.a when I run the php script.

You can look at my phpinfo here http://www.marreel.com/phpinfo.php

or look at the code snippet you sent me at http://www.marreel.com/curl.php

0
 

Author Comment

by:RobMarreel
ID: 12267112
Do I need to install the PHP source in to a specific location so the config will update the proper files? I have a feeling its not in the right localtion since phpinfo doesn't say anything about curl.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12267145
It seems that those curl-packes do not come with a library to link against. This generates those warnings and it seems the compiler is not able to build a useable module.

The only thing would be to build libcurl, libcrypt and openssl by our own so all needed libs are available and linkable for the php-curl module. It seems that the RedHat 6.2 is too old to add the curl-support very easy :-(

When your are trying to compile those packages with current version you might also need to upgrade automake autoxconf and libtool and this can get a pain.
As I don't have a RedHat 6.2 (and was not able to setup one within my vmware from the iso-images) I can't do such a build on one of my system and give you the libs and curl.so :-(

Best thing is to upgrade that server to a current version which also include security fixes, which might also come with a finished PHP and curl-support.

Sorry but to solve this problem is not so easy a it looked :-(

The location seem to be right, but the needed libs for curl are not available
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 12267156
It also seems that your extension_dir is not set properly in your php.ini
It should be  
extension_dir=/usr/local/lib/php/extensions/no-debug-non-zts-20010901

Have a look at that die if there is any file curl.* in  /usr/local/lib/php/extensions/no-debug-non-zts-20010901
0
 

Author Comment

by:RobMarreel
ID: 12301197
Well, although it wasn't the answer I was looking for. It pretty much looks like I need to update the OS. So you did answer my question. I will be upgrading everything and trying again.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to customise checkout order confirmation with variable products WooCommerce 6 58
mysql between clause 2 25
Loop through multiple arrays 13 29
Google Maps API and PHP 25 34
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

803 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