After the Mashed Museum day yesterday, I finally got in gear to see what the OpenCalais service could do to enrich the tags upon our blog post archives and forthcoming posts. To do this I used two separate plugins that have already been written and tested out by others (i’ll write about this in a separate post). However, to get this to work, I had to get the Curl library working on our main server (backup already functions) and to do this required a clean install of curl. So first off, I’ll be techie and explain how to get curl working on your linux box post installation of apache and PHP. Most of the articles I found talked about doing this prior to installing PHP.
First off once you’ve used your SSH client to login to your server, check that you don’t have curl already. Do this by issuing:
-
curl –version
You then need to download the source files that are appropriate for your OS. To do this issue the following command:
-
wget http://curl.haxx.se/download/curl-X.XX.X.tar.gz
(Replace the X.XX.X with the version that you require, I used an older version – 7.15.2 – as the latest version was incompatible with my PHP.)
This then needs to be unpacked, so issue the following command:
-
tar -xzf curl-X.XX.X.tar.gz
Then after unpacking navigate to the created folder:
-
CD curl-X.XX.X
Then issue:
./configure and wait for this to finish. Once done issue a make command and wait for this to finish and then once done issue make install (again wait for this to finish.) Now you can check that curl is working, so in my case I issued this command:
-
curl –version
-
curl http://www.finds.org.uk>test.txt
This then came back with the response:
% Total % Received % Xferd Average download Upload Speed Total Time Time Spent TimeLeft Current speed
100 20090 0 20090 0 0 5363 0 –:–:– 0:00:03 –:–:– 7329
To summarise, you will be issuing these commands in sequence:
- wget http://curl.haxx.se/download/curl-X.XX.X.tar.gz
- tar -xzf curl-X.XX.X.tar.gz
- ./configure
- make
- make install
- curl –version
- curl http://www.finds.org.uk >test.txt
Now you can proceed to recompile your version of PHP to include support for curl. First check your current configuration via your phpinfo file. Mine used to look like this:
-
‘./configure’ ‘-with-MySQL=/usr/share/mysql/’ ‘–with-apxs2=/usr/sbin/apxs’ ‘–with-XSL‘ ‘–with-gd’ ‘–with-jpeg-dir=/usr’ ‘–with-zlib-dir=/usr’ ‘–with-PNG-dir=/usr’ ‘–with-freetype-dir=/usr’ ‘–with-tidy’ ‘–enable-SOAP‘ ‘–with-magickwand=/usr/local/’ ‘–with-openssl’ ‘–enable-exif’
I want it to look like this:
-
‘./configure’ ‘-with-MySQL=/usr/share/mysql/’ ‘–with-apxs2=/usr/sbin/apxs’ ‘–with-XSL‘ ‘–with-gd’ ‘–with-jpeg-dir=/usr’ ‘–with-zlib-dir=/usr’ ‘–with-PNG-dir=/usr’ ‘–with-freetype-dir=/usr’ ‘–with-tidy’ ‘–enable-SOAP‘ ‘–with-magickwand=/usr/local/’ ‘–with-openssl’ ‘–enable-exif’ ‘–with-curl=usr/local’
Now using your SSH client, navigate to the folder with your current version of PHP installed eg. 5.04. Then issue the following command:
-
./configure –with-MySQL=/usr/share/mysql/ –with-apxs2=/usr/sbin/apxs –with-XSL –with-gd –with-jpeg-dir=/usr –with-zlib-dir=/usr –with-PNG-dir=/usr –with-freetype-dir=/usr –with-tidy –enable-SOAP –with-magickwand=/usr/local/ –with-openssl –enable-exif –with-curl=/usr/local/
Once finished, run the make command and then after this has run through, you will need to run make install to finish off the recompiled software. To summarise:
- ./configure –with-MySQL=/usr/share/mysql/ –with-apxs2=/usr/sbin/apxs –with-XSL –with-gd –with-jpeg-dir=/usr –with-zlib-dir=/usr –with-PNG-dir=/usr –with-freetype-dir=/usr –with-tidy –enable-SOAP –with-magickwand=/usr/local/ –with-openssl –enable-exif –with-curl=/usr/local/
- make
- make install
To make this take effect, you’ll need to restart your webserver and then recheck your phpinfo. The desired addition of with-curl should be implemented. You can then proceed to check that your PHP and curl play like lovely children in a playpen. This can be done by running the following PHP file:
-
$curl = curl_init();
-
curl_setopt ($curl, CURLOPT_URL, “http://www.britishmuseum.org”);
-
curl_exec ($curl);
-
curl_close ($curl);
The above script starts off by intitialising curl, the tells it to capture the URL mentioned and then print it out. So in this instance you’ll get the BM‘s homepage from that script on your domain.
Simple hey. You can then start to get more dangerous by writing screen scrapers to leverage you Google Analytics content for instance…..
OpenCalais helped to tag this with: Apache • Curl library • Google • http://www.britishmuseum.org • http://www.finds.org.uk • Linux • Mashed Museum • php
Possibly related posts: Gallery upgraded • Mashed Museum • Database upgrade work to commence •