Fatal error: Class 'SolrClient' not found

2019-07-21 17:32发布

问题:

I followed this tutorial to run solr using php. However I came across the above error. I looked into the SolrClient Class, but have no idea how to use it.

Is there a step by step guide for this?

回答1:

Please run the following commands

sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev
sudo apt-get install libpcre3-dev
sudo pecl install -n solr

Please add extension in php.ini file

sudo echo "extension=solr.so" >> /etc/php5/apache2/php.ini

Please create solr.ini file in /etc/php5/apache2/conf.d/ and add extension=solr.so in that file.

or run this command in terminal

sudo echo "extension=solr.so" > /etc/php5/apache2/conf.d/solr.ini

and restart apache

sudo /etc/init.d/apache2 restart

PHP-SOLR client is installed and ready to use.. :)



回答2:

If you are working in Ubuntu Nginx and php-pfm then try this.

sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev
sudo apt-get install libpcre3-dev
sudo pecl install -n solr

Create solr.ini file

sudo echo "extension=solr.so" >/etc/php5/fpm/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/cli/conf.d/solr.ini

Restart Nginx and php-fpm

sudo restart php5-fpm
sudo service nginx restart


回答3:

in Debian Linux :

sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev libpcre3-dev php5-dev
sudo pecl install -n solr
sudo echo "extension=solr.so" >/etc/php5/fpm/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/cli/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/cgi/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/apache2/conf.d/solr.ini

sudo /etc/init.d/php5-fpm restart
sudo /etc/init.d/apache2 restart


回答4:

In CentOS, execute the following commands:

  1. Install the dependencies:

yum install curl-devel libxml2-devel

  1. Install solr module

pecl install solr

  1. Add solr.so extension to php.ini

"extension=solr.so"

  1. Restart Apache:

systemctl restart httpd.service



标签: php solr