Over a million developers have joined DZone.

How to install solr PECL extension for PHP

DZone's Guide to

How to install solr PECL extension for PHP

· Web Dev Zone ·
Free Resource

Jumpstart your Angular applications with Indigo.Design, a unified platform for visual design, UX prototyping, code generation, and app development.

Lately, I have been working a lot with Solr. From setting up it on server using Tomcat, to creating its indexes, everything. I found that installing PECL extension for was bit challenging since it was not just about apt-get.apache solr logo How to install solr PECL extension for PHP

In fact, the complete setup sometimes becomes tedious job if not handled carefully, especially when you are not from the Java background or you have not done such setups in the past. So without wasting your much of time, let us start following the steps on how to install “Solr Pecl extension for PHP”.

The home of the Solr pecl extension is at Solr Pecl library page and I am downloading the solr 0.9.11 version for this post. Some people recommend to install it directly via “sudo pecl install solr” but that command did not work for me. Probably when you are reading this post, you might want to give it a try and skip the rest of the post, if that installs solr pecl extension for you.

Before we proceed further, there are some dependencies of this extension, lets install them first (if not install already).

Installing Curl

sudo apt-get install php5-curl

sudo apt-get install libcurl4-gnutls-dev

Installing phpize (it will be a part of libxml2)

sudo apt-get install libxml2

sudo apt-get install libxml2-dev

Now that you are done installing the above two dependencies, its time to install solr.

Extract the downloaded tar.gz file

tar -xvf solr-0.9.11.tgz

Type the following commands to configure, make and install solr.

cd solr-0.9.11




sudo make install

That should successfully install solr php extension. By default this extension was not activated in PHP, so here is what I did to activate the Solr php extension. The module file called solr.so was automatically kept in /usr/lib/php5/20060613+lfs/ in my case. And to load this extension, i did the following steps :

cd /etc/php5/conf.d/

sudo vi solr.ini

And pasted the following line inside solr.ini


Now restart your server, by typing apache2ctl restart and you should be able to see the solr extension in your phpinfo(); output.

I followed this method to install Solr Pecl extension for PHP. There are many ways to install the same, and you might have to skip or add some steps depending upon the packages present on your ubuntu box.

Hope that helps.

Stay Digified !!

Take a look at an Indigo.Design sample application to learn more about how apps are created with design to code software.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}