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.
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
phpize
./configure
make
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
extension=solr.so
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 !!
Sachin Khosla