Home Account

build php solr extension on ubuntu linux

2012-02-14 17:07 dennis iversen

Tags: apache2 solr php

Step By Step on Ubutnu 10.04

You will need the php5 development package:

sudo aptitude install php5-dev

Then you will need the php5-solr package found at the pecl solr page I downloaded the 1.0.2 release. I tried to build it but the system is kind to inform me that I'm missing the development files for curl and libxml, so they have to be installed.

sudo aptitude install libxml2-dev libcurl-dev

Depending on your system these two packages may be called something different. On Unbuntu 11.04 you will need: libcurl4-openssl-dev

then decompress, build and install the pecl solr package

tar xvfz solr-1.0.2.tgz
cd ./solr-1.0.2
phpize
./configure
make
sudo make install

You have now build the extension. Next thing to do is notify php that you have a new extension that you like to enable:

Finnally create and edit the following file:

sudo vim /etc/php5/apache2/conf.d/solr.ini 

And add the following line:

extension=solr.so

Then you will need to restart apache2:

sudo service apache2 reststart

Shell Script Install for Ubuntu 11.04

On Ubuntu 11.04 you can also run this script straight away:

#!/bin/sh
aptitude install libxml2-dev libcurl4-openssl-dev php5-dev
wget http://pecl.php.net/get/solr-1.0.2.tgz
tar xvfz solr-1.0.2.tgz
cd ./solr-1.0.2
phpize
./configure
make
make install
echo "Creating config file for solr\n"
echo "extension=solr.so" > /etc/php5/apache2/conf.d/solr.ini
service apache2 restart

Save as e.g install_solr.sh, and execute

sudo ./install_solr.sh

This page has been requested 5434 times