Installing and upgrading help

Installing Solr for Global Search in Moodle

 
Picture of Fire Moodle
Installing Solr for Global Search in Moodle
 

I have installed Moodle 3.1 onto my laptop so I can have an offline testbed.

I want to get Global Search working but haven't so far found a step by step guide on how to install Solr and get it  running in Windows so that Moodle can use it.

I have followed the various guides on this forum but have so far had no luck.

I'm using Moodle 3.1 installed on Standalone Windows 10 Laptop


 
Average of ratings: -
Picture of Jeff Noel
Re: Installing Solr for Global Search in Moodle
 

Starting Solr on Windows

You need to start Solr for it to work.

I used the following guide to make it work as a service: https://www.norconex.com/how-to-run-solr5-as-a-service-on-windows/

If you open the solr dashboard (which should be at the url http://localhost:8983 ) you should be able to see your Solr cores.

You need to setup a core so Solr can start indexing things.


Setupping a Solr Core

You can copy the folder located in your_solr_folder/server/solr/configsets/basic_configs (named conf) in a new folder which will be the name of your core, for example: your_solr_folder/server/solr/moodle_dev

Then, simply restart your Solr service and it should automatically run the new core, which will be detected by your Moodle instance.

You can confirm the core is there by going back in your Solr dashboard, in the Core Admin page.


If you get a core.properties error, try putting a core.properties file within your core folder and put the following code in it:


</lst>=
name=moodle_dev
</requestHandler>=
<str=name\="collection_name">moodle_dev</str>
<requestHandler=name\="/select">
<lst=name\="defaults">


This is what I did to make it work using Solr 6.0.1 and Moodle 3.1



I still can't see the global search icon on the top of the screen, but the blocks are working fine (that's just a problem of mine, not related to your issue).

 
Average of ratings: Useful (3)
Picture of Fire Moodle
Re: Installing Solr for Global Search in Moodle
 

Thanks so much for passing along that guidance.  I now have Solr running on the computer but I don't know how to integrate this with Moodle so that it can see Solr.

I am still getting the same error message.

I have downloaded the pecl solr-2.4.0 as the installation instructions say but so far haven't found where to place it.

 
Average of ratings: -
Picture of Jeff Noel
Re: Installing Solr for Global Search in Moodle
 

Hi again,


I totally forgot to mention that part in my first reply.

You need to put the php_solr.dll file (which should be a part of all the files downloaded in the pecl zip file) within your PHP installation folder, in the folder "ext".

Then, edit your php.ini file (located at the root folder of your PHP installation). 

Use CTRL+F to find the following string within the file: [ExtensionList] (should be almost at the end of it)

There should be a few lines beginning with "extension=" right beneath it. Simply add one line which consists of:

extension=php_solr.dll

Note: You can put the line anywhere within the file, but if you want to keep things ordered I suggest putting it there!

Save the file.


Restart your PHP instance (usually, restarting Apache does it for you). 


You can then confirm that the Solr pecl is loaded correctly by going back to your Global Search/Solr configuration page on Moodle. It should be detected just fine.


It's quite interesting that I faced the same issue as you do, a few hours before you. I thought it was surprising that Moodle didn't include a guide for Solr on Windows.


If you have any questions, feel free to ask. Sorry for the average quality of this reply, it's friday afternoon! ;)

 
Average of ratings: Useful (1)
Picture of Fire Moodle
Re: Installing Solr for Global Search in Moodle
 

Thanks again for you help.

I have copied the dll into the ext folder and also made the change to the php.ini file.

Now when I stop and start Apache in Xampp I get an error message:

PHP Startup: Unable to load dynamic library 'C:\Moodle\Moodle 31\Server\ext\php_solr.dll' - The Specified module could not be found.

 
Average of ratings: -
Picture of Jeff Noel
Re: Installing Solr for Global Search in Moodle
 

Hi,


It might sound like an awkward question, but did you make sur the dll file is correctly named php_solr.dll (no capital letters) and is in the folder "C:\Moodle\Moodle 31\Server\ext\" ?

Just make sure the folder "Moodle\Moodle 31\Server" is indeed your PHP installation folder.

In XAMPP, the default path is alike the following: C:\xampp\php\php.ini

You also need to make sure you got the right PECL package depending on your PHP version and whether it's thread safe or not.


 
Average of ratings: -
Picture of Fire Moodle
Re: Installing Solr for Global Search in Moodle
 

I'm using the Xampp control that comes in the Moodle server folder to control Apache etc...  Should I install my own instance of XAMPP?

XAMPPP is finding the php.ini because if I comment out the php_solr.dll, Apache starts with no error messages.

All the spellings are correct with no uppercase. 

Does another .dll need to be enabled for solr to work?

I have tried a variety of .dlls both threaded and not-threaded. 

The PHP that is in the Moodle server folders is 5.4.25.  I'm using the pecl for php 5.4

 
Average of ratings: -
Picture of Ken Task
Re: Installing Solr for Global Search in Moodle
Particularly helpful Moodlers

Dunno how one compiles pcel_php_solr on Windows (that's what I had to do
on CentOS 6).

But there is a download link for a .dll - just have to pick a compat version, me thinks (don't run Windows so others will have to take over from here on that!)

https://pecl.php.net/package/solr

https://github.com/php/pecl-search_engine-solr

'spirit of sharing', Ken

 
Average of ratings: -
Picture of Jeff Noel
Re: Installing Solr for Global Search in Moodle
 

Perfect, we got that sorted out.

Now, it seems like it cannot find the dll (there's not additionnal dll files to load, only php_solr.dll), so we might want to check in the php.ini file for the extension_dir parameter.

Make sure it points to the directory where your php_solr.dll file is located. If it's not the case, relocate your dll file (do not edit this parameter as your PHP instance will start crashing if you use additionnal extensions).

 
Average of ratings: -
Picture of Fire Moodle
Re: Installing Solr for Global Search in Moodle
 

The extension_dir points to; C:\Moodle\Moodle 31\Server\php\ext\php_solr.dll

That is also the location that the php_solr.dll is in.

I have triple checked this.  And just to see what would happen I put a 64-bit version of the dll into the directory and I got a different error message. 

PHP startup: Unable to load dynamic library 'C:\Moodle\Moodle 31\server\ext\php_solr.dll' - %1 is not a valid Win32 application.

I wasn't expecting the 64-bit version to work but thought I would try it anyway.

That to me says that the dll is in the location referred to in php.ini but for some reason the x86 version isn't playing ball.

 
Average of ratings: -
Picture of Jeff Noel
Re: Installing Solr for Global Search in Moodle
 

Another thing to check is the thread-safe vs NTS version of the dll. You should try both (as long as they're made for the PHP version you're running) and see if one or the other works, or even if the error message changes again.

 
Average of ratings: -
Picture of Fire Moodle
Re: Installing Solr for Global Search in Moodle
 

Thanks again for you reply.  I have tried a variety of TS and NTS dlls but had no luck.

I have the same error message for x86 dlls.  And the other same message for x64 dlls.

Luckily I have been able to gain access to another server that runs Global search so I could try it out there.

I might have to chalk this up to another of Window's foibles.

Thanks to everyone that has tried to help.  Especially you Jeff.

 
Average of ratings: -
moodler
Re: Installing Solr for Global Search in Moodle
 

Hi there,

For those who want to install Solr on Windows I recommand the Bitnami Solr stack (https://bitnami.com/stack/solr).

This stack avoid using of NSSM to start Solr Windows service and is easier to install.

 
Average of ratings: Useful (1)
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Upgraded to Moodle 3.1 and no luck on  working it successfully. We are using Unix environmentSearch Engine

 
Average of ratings: -
Picture of Hermann Klocker-Mark
Re: Installing Solr for Global Search in Moodle
 

Had the same problem. Worked after creating a new core in solr called moodle - the same name as given in the moodle configuration.

To create core you have to create the directories first.

 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Able to create a new core but still no luck same status

 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Where can I locate the name on the moodle configuration?

 
Average of ratings: -
Picture of Julios Ribeir
Re: Installing Solr for Global Search in Moodle
 

Daar is verskeie ander vorme van navrae binne die Lucene navrae wat ons in staat stel om die data te filtreer in ons dokument basis Solr. Vir meer besonderhede,  senha kan jy 'n handleiding oor die Lucene navrae op die skakel hieronder te vind: http://lucene.apache.org/core/2_9_4/queryparsersyntax.html Die doel van die volgende dele van ons artikel Apache Solr, sal ons gaan met: - Stel die data skedule binne die Apache Solr. Dankie!

 
Average of ratings: -
Picture of Ken Task
Re: Installing Solr for Global Search in Moodle
Particularly helpful Moodlers

@Ron ... would suggest, if that paths I see are indeed correct in the screen snap, that /root/ is a bad location for solr ... which has to be accessed via web.   Think install directions I have seen suggest installing in /opt/.   Can't tell by your screen shot IF you were using a browser in the GUI of the server itself or not.   If not, and from a workstation, access to /root/ for any web based would make me nervous.

'spirit of sharing', Ken

 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Thanks Ken for the tips, I might moved to different path once it's work on our dev environment. do you have any idea why it still No Solr configuration found? the screen shot I accessed it from my workstation.

 
Average of ratings: -
Picture of Hermann Klocker-Mark
Re: Installing Solr for Global Search in Moodle
 

I can show my config (Ubuntu 16.04, solr 6.1.) which worked finally. In moodle config I noticed weird 0 values instead of none so I entered all the values shown. Notice the label 'Indexname' which should be 'Core name' (at least for my solr version).

I agree with @Ken that your directories could be a bad choice - I just selected the same as for the default core 'gettingstarted' which is a directory owned to solr.

root@server:/var/www/moodle# ls -lah /var/solr/data/

total 20K

drwxr-x--- 4 solr solr 4.0K Jul 13 20:53 .

drwxr-x--- 5 solr solr 4.0K Jul 13 15:06 ..

drwxrwxr-x 4 solr solr 4.0K Jul 13 15:07 gettingstarted

drwxr-xr-x 4 solr solr 4.0K Jul 13 20:57 moodle

-rw-r----- 1 solr solr 2.1K Jul 13 15:06 solr.xml

root@server:/var/www/moodle# ls -lah /var/solr/data/moodle/

total 96K

drwxr-xr-x 4 solr solr 4.0K Jul 13 20:57 .

drwxr-x--- 4 solr solr 4.0K Jul 13 20:53 ..

drwxr-xr-x 3 solr solr 4.0K Jul 13 20:55 conf

-rw-rw-r-- 1 solr solr  151 Jul 13 20:57 core.properties

-rw-r--r-- 1 solr solr 3.9K Jul 13 20:55 currency.xml

drwxr-xr-x 4 solr solr 4.0K Jul 13 20:57 data

-rw-r--r-- 1 solr solr  29K Jul 13 20:55 managed-schema

-rw-r--r-- 1 solr solr  873 Jul 13 20:55 protwords.txt

-rw-r--r-- 1 solr solr   33 Jul 13 20:55 _rest_managed.json

-rw-r--r-- 1 solr solr  22K Jul 13 20:55 solrconfig.xml

-rw-r--r-- 1 solr solr  781 Jul 13 20:55 stopwords.txt

-rw-r--r-- 1 solr solr 1.1K Jul 13 20:55 synonyms.txt





 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Thanks Herman, Sorry I am not that expert on Linux where can find the moodle config? under config.php?

The reason I also installed on the root because just followed step here.  https://cwiki.apache.org/confluence/display/solr/Installing+Solr

[root@DEV-MOODLE moodle]# ls -lah /root/solr-5.3.0/server/solr/

total 40K

drwxr-xr-x.  7 root   root   4.0K Jul 14 22:14 .

drwxr-xr-x. 11 root   root   4.0K Sep 10  2015 ..

drwxr-xr-x.  5 root   root   4.0K Aug 12  2015 configsets

drwxr-xr-x.  3 apache apache 4.0K Jul 14 19:37 core

drwxr-xr-x.  4 root   root   4.0K Jul 14 22:14 Index

drwxr-xr-x.  4 apache apache 4.0K Jul 14 21:47 moodle

drwxr-xr-x.  3 root   root   4.0K Sep 15  2015 new_core

-rw-r--r--.  1 root   root   3.0K Aug 12  2015 README.txt

-rw-r--r--.  1 root   root   1.9K Aug 12  2015 solr.xml

-rw-r--r--.  1 root   root    501 Aug 12  2015 zoo.cfg

[root@DEV-MOODLE moodle]# ls -lah /root/solr-5.3.0/server/solr/moodle/

total 24K

drwxr-xr-x. 4 apache apache 4.0K Jul 14 21:47 .

drwxr-xr-x. 7 root   root   4.0K Jul 14 22:14 ..

drwxr-xr-x. 5 apache apache 4.0K Jul 14 21:43 conf

-rw-r--r--. 1 root   root    129 Jul 15 02:52 core.properties

-rw-r--r--. 1 root   root    131 Jul 14 21:45 core.properties.unloaded

drwxr-xr-x. 4 root   root   4.0K Jul 14 21:45 data


 
Average of ratings: -
Picture of Hermann Klocker-Mark
Re: Installing Solr for Global Search in Moodle
 

Hi Ron,

moodle config is the moodle page: 

HomeSite administrationPluginsSearch

Solr

The creation of a new core was a bit of experimentation & intuition too - I know nothing about Solr and could not find an easy tutorial. What I did (as root) was - this should produce the previous structures:

mkdir /var/solr/data/moodle

mkdir /var/solr/data/moodle/data

cd /opt/solr/server/solr/configsets/basic_configs

cp -R conf /var/solr/data/moodle

chown -R solr:solr /var/solr/data/moodle



After this the first two directories are the one Solr wants when creating a new core. Doing a Indexing via moodle gave positive statistics in the Solr panel. In addition to this I created a cron job (not sure about this to be necessary) and now moodle is indexing every 5 minutes for new documents.


*/5 * * * *     root    /usr/bin/php /var/www/moodle/search/cli/indexer.php 


 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Thanks Herman, I could not open the configuration it's telling me that apache solr PHP extension is not installed. just wondering why I get this error but I could accessed  http://localhost:8983/solr/admin/

 
Average of ratings: -
Picture of Hermann Klocker-Mark
Re: Installing Solr for Global Search in Moodle
 

OK, that should be not too hard: you have to tell apache to use solr, this depends on your system/php Version. For me using php 7 I decided to write the important line

extension=solr.so

into /etc/php/7.0/mods-available/solr.ini

and link to this file in /etc/php/7.0/apache2/conf.d:

solr.ini -> ../../mods-available/solr.ini

But you can write the first line into php.ini of apache for other installations. Don't forget to restart apache afterwards, e.g. 

apache2ctl restart

This, again, is for Ubuntu/Linux, for Windows you have to use .dll,

 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Still no luck

Created solr.ini and write extension=solr.so

Link to /etc/httpd/conf.d/ then restart the apache

 cd /etc/httpd/conf.d/

[root@DEV-MOODLE conf.d]# ll

total 76

-rw-r--r--. 1 root root 1974 Jan 13  2015 fastcgi.conf

-rw-r--r--. 1 root root 1510 Jan 13  2015 fastcgi.conf.orig

-rw-r--r--. 1 root root  295 Jul 12 07:00 manual.conf

-rw-r--r--. 1 root root 1796 Apr 22  2005 perl.conf

-rw-r--r--. 1 root root 1046 Jun 21 08:24 php.conf

-rw-r--r--. 1 root root 1046 Dec 17  2014 php.conf.dis

-rw-r--r--. 1 root root  392 Jul 18 16:13 README

lrwxrwxrwx. 1 root root    8 Jul 19 09:13 solr.ini -> solr.ini

-rw-r--r--. 1 root root 9807 May 10 09:28 ssl.conf

-rw-r--r--. 1 root root 9867 May 10 09:28 ssl.conf.oops

-rw-r--r--. 1 root root 9465 Mar  3  2015 ssl.conf.rpmnew

-rw-r--r--. 1 root root  352 Sep  9  2004 webalizer.conf

-rw-r--r--. 1 root root  299 Jul 12 07:00 welcome.conf

-rw-r--r--. 1 root root   43 Jun 11  2014 wsgi.conf

[root@DEV-MOODLE conf.d]#  service httpd restart

Stopping httpd:                                            [  OK  ]

Starting httpd:                                            [  OK  ]


And also I added the extension=solr.so on php.ini 

 
Average of ratings: -
Picture of Ken Task
Re: Installing Solr for Global Search in Moodle
Particularly helpful Moodlers

We ALL need to share what platform running ... Ubuntu isn't the same as CentOS and certainly NOT the same as Windows!!!!   Moodle code *might* be able to be run on Linux/Windows/Macs but Apache Solr PHP ... it's an extension to Apache which actually references something driven by Java RT ... NOT javascript.

There are slight enough differences where platform needs to be known.

This response directed @Ron because I think he's running RHEL or CentOS ...

This line:

lrwxrwxrwx. 1 root root    8 Jul 19 09:13 solr.ini -> solr.ini

Is a symlink ... that appears to point to itself.   Certainly not going to work like that. ;)

Installation of Solr Apache extension on CentOS boxen:

First, let's see if the solr php extension is really installed:

php -m |grep solr

should response with nothing but the word 'solr'.   IF it doesn't, then the PHP solr extension is NOT installed.

This might help:

https://gist.github.com/tegansnyder/8691289

All the Apache modules (so files) should be in /usr/lib64/php/modules/ and they should ALL be executable by all (the 'x' reference in the listing of the solr.so file (which is 1130255 bytes in size) :

-rwxr-xr-x. 1 root root 1130255 Jun  9 20:22 /usr/lib64/php/modules/solr.so

In Apache on CentOS, all the .conf files in /etc/httpd/conf.d are loaded last.

in /etc/httpd/conf.d there should be a solr.ini file which has only this one line:

extension=solr.so

All 'extensions' to apache config are found in /usr/lib64/php/modules/ so that's why there is no path after extension= ... just the name of the .so file (solr.so).

Restart Apache service: /sbin/service httpd restart

Not mentoned and think it's needed is a setting to iptables in CentOS/RHEL firewall

-A INPUT -p tcp -m tcp -m state --dport 8983 --state NEW -j ACCEPT

Port 8983 is the JRE service for Solr IF that service has been launched.

I use a text based browser on CentOS to test called lynx ... could use elinks (could install either of those via yum).

lynx http://localhost:8983/solr/

If you see a solr admin/config screen then solr is running.

How about we stop at this point and get that much going.

BTW, had it running on a CentOS 6 box about 2 weeks ago.  Was testing what search found.   Updated the moodle to 3.1.1 just other day and now search is broke ... like another poster in this thread am seeing the same thing ... path sure looks strange to me /solr/Moodle/admin/system/ ????  Thought before it had reported /solr/moodle ... the 'moodle' from what I gather is the index built from the command line for Moodle search to use .... so where is admin/system?   Those diretories don't exist ... not even in the exampledocs one could find in /opt/solr/core/exampledocs/

which is an example index provided with the package and looks like:

books.csv            hd.xml          manufacturers.xml  monitor2.xml      mp500.xml    sd500.xml      test_utf8.sh
books.json           ipod_other.xml  mem.xml            monitor.xml       post.jar     solr-word.pdf  utf8-example.xml
gb18030-example.xml  ipod_video.xml  money.xml          more_books.jsonl  sample.html  solr.xml       vidcard.xml

Moodle, however, isn't indexing books nor manufacturers etc..

So I too am a little confused ... we're all in this together, are we not? ;)

'spirit of sharing', Ken




 
Average of ratings: -
Picture of Ken Task
Re: Installing Solr for Global Search in Moodle
Particularly helpful Moodlers

Responding to own post ... finally found my error ... search broken after upgrade from 3.1+ to 3.1.1 NOT due to the upgrade nor any change in Moodle code.

Explain how stupid I have been ... after successfully installing and testing, kept seeing the solr home was set to /var/solr/ so decided to test by hiding the 'moodle' index that it was using by renaming the directory: mv moodle .moodle in /opt/solr/server/solr/cores/ where the index was built.

In other words ... broken between the keyboard and the chair. :\

The following for Centos 6 ... since the Moodle server behind a boundary firewall that doesn't have the solr port opened had to use the command line to setup and configure solr - thus Moodle search.  For those reading ... this may/may not work for you but hopefully, it might point you in the right direction

** on a Linux box**.

Another potential catch 22 to this posting ... haven't another CentOS 6 server with Moodle 3.1.x on it yet to replicate what I did to assure the directions below are indeed accurate.

The following from notes that I hope I have correct.

** You've been WARNED! **

As root user:

PHP-SOLR
========
cd /root
git clone https://github.com/ecaron/php-pecl-solr.git
cd php-pecl-solr
phpize
./configure
make
make install

ls /usr/lib64/php/modules/
should see a solr.so file in the above directory

nano /etc/php.d/solr.ini
add to the above file the following line:

extension=solr.so

/sbin/service httpd restart
php -m
should show solr in the listing of php extensions
php -m |grep solr
should respond with solr

APACHE SOLR - CentOS 6
======================

This one is tricky ... and does require JRE at least version 1.8
Oracle pulled the 1.7 offline just the other day.

As root user: java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

I had to download the 1.8 to laptop and then scp it back up to server in /opt/
(just to keep things in the same place)
http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz

in /opt as root where jdk-8u91-linux-x64.tar.gz resides

tar xvf jdk-8u91-linux-x64.tar.gz
then used alternatives to install (you could already have a java 1.6 or 1.7 installed and should be using the latest.

/usr/sbin/alternatives --install /usr/bin/java java /opt/jdk1.8.0_91/bin/java 2

You'll get a screen asking which number to setup.

Check version: java -version as above.

Apache SOLR does require a user: solr

/usr/sbin/useradd solr

cd /opt/
wget http://www.us.apache.org/dist/lucene/solr/6.0.1/solr-6.0.1.tgz
tar zxvf solr-6.0.1.tgz
cd solr-6.0.1 solr
bin/install_solr_service.sh /opt/solr-6.0.1.tgz -f
bin/solr create -c moodle
chown solr:solr * -R

****DO NOT remove /opt/solr-6.0.1 solr directory.

Had to open access to port 8983 in iptables

Check to see if there is a solr file in /etc/init.d/   That means solr will start up on reboots.

Should have been created upon install.

ps aux |grep java
should show solr running.

In Moodle config for solr
Host: localhost
Port: 8983
Index: moodle

Then start playing with search.

TIP: indexing in solr of new docs, files upload to Moodle site  can be 'forced' update (re-index/add to index) two ways:

cron/task list

or via command line from moodle code directory:

php search/cli/indexer.php

'spirit of sharing', Ken

Am now gonna treat myself to a cold beer!  (and also use the can to reduce the swelling of my forehead for banging it too often over the last couple of days! :\)  (no icon for cold beer?!!!)



 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Thanks Ken. I tried all your step but still no lucks. 

Able to create new core

But still not able to setup search engine and Index data


 
Average of ratings: -
Picture of Ken Task
Re: Installing Solr for Global Search in Moodle
Particularly helpful Moodlers

Thanks for the attached text file .. shows what you've checked.   For the benefit of others who might follow a checklist for CentOS 6 (and probably 7 - and should work with Ubuntu [maybe]);

What's under the  'setup search engine' link in the Moodle Admin UI?

Solr CentOS 6 Server Checks

Have solr apache/php extension installed and loaded?

php -m |grep solr

should show the module is present and the above command responds with:

solr

Have the Apache Solr running as a service on bootup?
Find out if there a 'solr' file in /etc/init.d/?

Apache Solr must run user 'solr'.   Does solr user exist on system?

getent passwd solr

should show something like:
solr:x:501:501::/opt/solr:/bin/sh

Do the moodle core files for indexing belong to user 'solr'?

cd /opt/solr/server/solr/cores/
ls -lR

should see the index: moodle and all files related in that directory
with user:group solr:solr

Is the JRE service for solr running?

ps aux |grep java

One should see something that begins like:

solr     20208  0.0  1.4 4498500 235260 ?      Sl   Jul15   4:10 java -server
with a bunch more info ... you'll see ports in the info.

Port opened in firewall? *IF running a firewall (iptables)

/sbin/iptables -S

In the listing one should see the solr port not by name but by rule is allowed (the fact you can get to the solr admin interface from a workstation browser (not localhost) may indicate not running a firewall on the server (iptables) but the server is still protected by the WAN/LAN boundary firewall.   Your screen shot for the solr admin didn't show the URL so that might have been localhost.

You're installation is slightly different than mine ... which doesn't mean yours shouldn't work.

Location of the index for 'moodle'.  Mine is in /opt/solr/server/solr/cores/ What counts at this point is how the java service was launched and where it's pointed.   Yours in another location.

So will ask again:

** What's under the  'setup search engine' link in the Moodle Admin UI? **

'localhost' should be found in /etc/hosts   By default now it might use the IPv6 reference to localhost and your server is still IPv4.   Know apache startup likes to find itself in localhost/DNS or it will complain.

And the last line in the attached .txt file showed the running of indexer.php that reported a time zone Notice.   Set in php.ini the correct time zone.    Don't know that affects solr or not but would think the index would need accurate date/time, etc. information - even if it's not displayed in Moodle UI to search.

Other than that ... don't know what to tell ya! :\

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

** What's under the  'setup search engine' link in the Moodle Admin UI? **

Here were the link go after I click the setup search engine.


I attached again txt file for all the response on the above command

Picture of Ken Task
Re: Installing Solr for Global Search in Moodle
Particularly helpful Moodlers

Two things ... appears apache still doesn't know about php-solr extension.   After you made the edits/changes to the setup of php-solr did you restart the apache process?    Did you check for php -m |grep solr

Going to the admin interface for solr via http://localhost:port/solr/ am not sure that's actually using apache.   Interaction with solr in Moodle has to be done via apache to whatever is in front of solr.

It appears we've not found where the 'moodle' core resides.   Have been showing you commands from the perspective of where I've installed solr index for Moodle.    Doesn't really mean that you did it exactly the same way.   I *had* to use command line ... you could use the apache admin to solr to create the index for Moodle.

So one command I gave you to check should have been adjusted to your server setup.

I had mistakenly given you:

cd /opt/solr/server/solr/cores/
ls -lR

So let's try this:

cd /opt/solr

The 'moodle' core index should be somewhere in there, I think!

find ./ -name moodle

That's if you named the index 'moodle'.   Would/should return where it found the directory where the index is stored.

On mine, the above command shows:

./server/solr/cores/moodle

./ means present working directory so that's /opt/solr/ ... where we issued the find command.

and inside of there ... server/solr/cores/moodle is where my index resides.

Your core 'moodle' should be somewhere in /opt/solr I think.

And, let's see if your server can find a solr service:

/sbin/service solr status

'spirit of sharing', Ken


 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Yes I restart the apache and here is what php -m |grep solr response

[root@DEV-MOODLE solr]# php -m |grep solr

solrs

Here screen shot of  http://localhost:port/solr/ 


[root@DEV-MOODLE solr]# /sbin/service solr status


Found 1 Solr nodes:


Solr process 10822 running on port 8983

{

  "solr_home":"/var/solr/data",

  "version":"6.1.0 4726c5b2d2efa9ba160b608d46a977d0a6b83f94 - jpountz - 2016-06-13 09:46:58",

  "startTime":"2016-07-20T13:44:30.622Z",

  "uptime":"1 days, 17 hours, 58 minutes, 20 seconds",

  "memory":"22.2 MB (%4.5) of 490.7 MB"}


 
Average of ratings: -
Picture of Hermann Klocker-Mark
Re: Installing Solr for Global Search in Moodle
 

Hi Ron,

don't want to interfere and didn't read your whole conversation with Ken but IMO you have to separate in your thinking two totally different aspects:

1. Solr is totally independent from Apache, it seems to be running fine, it even has an index (although without objects).

2. Apache is not connected to it and thus moodle can't find it. I suggest trying also

php -i | grep -C3 solr


and/or looking at your moodle/adminstration/server/php-info:


http://your.moodle.site/admin/phpinfo.php


Both should give more information about item 2.

 

 
Average of ratings: Useful (1)
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Here is the response

[root@DEV-MOODLE etc]# php -i | grep -C3 solr

/etc/php.d/simplexml.ini,

/etc/php.d/soap.ini,

/etc/php.d/sockets.ini,

/etc/php.d/solr.ini,

/etc/php.d/sqlite3.ini,

/etc/php.d/sysvmsg.ini,

/etc/php.d/sysvsem.ini,

--


Sockets Support => enabled


solr


Solr Support => enabled

Version => 2.4.0

Attached below is the PHP info

 
Average of ratings: -
Picture of Hermann Klocker-Mark
Re: Installing Solr for Global Search in Moodle
 

So php sees solr on the command line (which is php -i) but not for apache (which is php-info). So solr.so should be ok and in a good location and cli php can use it, apache not. Could you test:

find /etc -name solr.ini

find /etc -name php.ini


and look at the content of (the right) solr.ini/php.ini?, which should be (I presume):


extension=solr.so


Are you sure you have the "extension=" statement in the right file/location? Check your documentation.

 
Average of ratings: -
Picture of Ken Task
Re: Installing Solr for Global Search in Moodle
Particularly helpful Moodlers

Glad you've jumped in ... maybe you can spot something I've not been able to see (evidently OP 'trust' you [rating]) so I'll back away for a while and let you two continue.

Just to make sure you both are on the same page ... saw in a previous posting about similar issue you are running CentOS 7.1   Op is running 6.x.    There is a diff. ... suttle, but still enough to confuse.

One thing for anyone reading ... Moodle code will not create the 'moodle' collection in solr even if you see it in the config.    That collection has to be created in one of two ways ... via solr's web interface (which is really JavaRunTime web - not apache) or via command line.

Keep in mind that the php-solr extension is for apache/thus Moodle code to be able to talk to that JRE web server running on a different port.    When mine broke (operator was responsible), was getting an error showing 404 and a path ... /solr/moodle/admin/system

The 'moodle' in that path is the collection previously created.   Collection actually has more to it that just the moodle stuff ... xml files, other directories etc. you don't see in Moodle but must be present.

I inspected the code for search and found that path is a 'hard coded' /solr ... which to Moodle and Apache is supposedly at root of the drive ... actually in /var/solr/ on CentOS 6 IF one installed one way but the collection could be a core located in /opt/solr/server/solr/cores/moodle depending upon how that core was created.

Ok ... that was my last 2 cents.

'spirit of sharing', Ken

 
Average of ratings: -
Picture of Hermann Klocker-Mark
Re: Installing Solr for Global Search in Moodle
 

@Ken - I don't think I know as much as you, especially I know nothing about CentOS. I just remember some important points from my struggling. So both of us contribute (as your footer says smile ).

But here is one observation for @Ron:

The apache status given by php-info.php lists the directories searched for inclusion:

Scan this dir for additional .ini files

/etc/php-zts.d

Additional .ini files parsed

/etc/php-zts.d/bz2.ini, /etc/php-zts.d/calendar.ini, /etc/php-zts.d/ctype.ini, /etc/php-zts.d/curl.ini, /etc/php-zts.d/dom.ini, /etc/php-zts.d/exif.ini, /etc/php-zts.d/fileinfo.ini, /etc/php-zts.d/ftp.ini, /etc/php-zts.d/gd.ini, /etc/php-zts.d/gettext.ini, /etc/php-zts.d/iconv.ini, /etc/php-zts.d/intl.ini, /etc/php-zts.d/json.ini, /etc/php-zts.d/ldap.ini, /etc/php-zts.d/mbstring.ini, /etc/php-zts.d/mysqlnd.ini, /etc/php-zts.d/mysqlnd_mysql.ini, /etc/php-zts.d/mysqlnd_mysqli.ini, /etc/php-zts.d/opcache.ini, /etc/php-zts.d/pdo.ini, /etc/php-zts.d/pdo_mysqlnd.ini, /etc/php-zts.d/pdo_sqlite.ini, /etc/php-zts.d/phar.ini, /etc/php-zts.d/posix.ini, /etc/php-zts.d/shmop.ini, /etc/php-zts.d/simplexml.ini, /etc/php-zts.d/soap.ini, /etc/php-zts.d/sockets.ini, /etc/php-zts.d/sqlite3.ini, /etc/php-zts.d/sysvmsg.ini, /etc/php-zts.d/sysvsem.ini, /etc/php-zts.d/sysvshm.ini, /etc/php-zts.d/tokenizer.ini, /etc/php-zts.d/xml.ini, /etc/php-zts.d/xml_wddx.ini, /etc/php-zts.d/xmlreader.ini, /etc/php-zts.d/xmlrpc.ini, /etc/php-zts.d/xmlwriter.ini, /etc/php-zts.d/xsl.ini, /etc/php-zts.d/zip.ini


which is not only non-standard (I think) but also without the necessary solr.ini. So probably just copying (or better: linking) the file to this location should solve this problem (restart Apache!).


 
Average of ratings: Useful (1)
Picture of Ken Task
Re: Installing Solr for Global Search in Moodle
Particularly helpful Moodlers

+1 Herrman!

Thanks for your kindness ... SEE, I needed to back away cause I saw that in one of the .txt files he's shared and thought nothing of it. sad

Dunno why but never considered running PHP with Thread Safety cause Apache supposedly handles handles that IF running apache a certain way.   Seems TS is still kinda debatable.

Annyyyyhoooo ... I hope that what you have spotted will get the OP on down the road and working! ;)

'spirit of sharing', Ken

 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 

Hi, Sorry for the late response. I already added solr.ini to php-zts.d. Still not working sad


[rv6048@DEV-MOODLE ~]$ locate solr.ini

/etc/php-zts.d/solr.ini

/etc/php.d/solr.ini

[rv6048@DEV-MOODLE ~]$ cat /etc/php-zts.d/solr.ini

extension=solr.so


 
Average of ratings: -
Picture of Hermann Klocker-Mark
Re: Installing Solr for Global Search in Moodle
 

OK, now solr.ini is seen/parsed (different from your attached previous file). So your php-info should have a section almost at the bottom listing details, could you check? Now I am out of ideas too - maybe a reboot would help smile :

solr

Solr Supportenabled
Version 2.4.0 
Last Build Date Jul 13 2016 
Last Build Time 15:27:39 

 
Average of ratings: -
Picture of Ron Vitug
Re: Installing Solr for Global Search in Moodle
 
The solr section is not showing on php.info I also did the reboot. I am thinking to revert back to moodle 2.7 and re upgrade it again.
 
Average of ratings: -
Picture of Ambrish Tiwari
Re: Installing Solr for Global Search in Moodle
 

I have configured the Solr on windows and gone through the every step, but i am getting the above error. Can you tel how to resolve it.

I am using moodle 3.1

 
Average of ratings: -
moodler
Re: Installing Solr for Global Search in Moodle
 

Hi Ambrish Tiwari,

      Did check that a core exists and is deployed with the name you gave for "search_solr | indexname" into :

https://[yourmoodlesite.com]/admin/settings.php?section=searchsolr

The core folder must be into : "C:\[install-path]\solr-6.2.1-1\apache-solr\server\solr"

It had to be deployed into core admin > add core in your Solr UI : http://localhost:8983/solr/



 
Average of ratings: -
moodler
Re: Installing Solr for Global Search in Moodle
 

Hi there,

    I'm currently using Solr on multiple Windows web instances with no problems, but now I'm looking for a way to use it on all of my Moodle sites (more than 500 sites actually).

Following what I red on forums I need to create 1 core per Moodle site, so I'm just wondering the way to create cores entirely from the command line to automize that into a config script.

Does anyone know how I can deploy Solr cores (assuming core folder already exists into "~\solr-6.2.1-1\apache-solr\server\solr") by command line on Windows ?

Thanks in advance.

 
Average of ratings: -
moodler
Re: Installing Solr for Global Search in Moodle
 

ok I finally found it, quite easy when you have identified the right command.

If you have properly configured your core folder before, you just need those commands :

cd "C:\[install-path]\solr-6.2.1-1\apache-solr\bin"

solr create_core -c [core_name]


 
Average of ratings: -
Picture of sai prasad
Re: Installing Solr for Global Search in Moodle
 

Hey Gabriel,

Could you let me know the steps you did for installing solr on windows server 2012, im struggling to install it. I appreciate your help.

below are the steps i did:

Hi i have followed all the instructions but still couldnt install php solr on my windows server 2012.

i have installed APACHE solr and started through command prompt and it started at port 8983 on my localhost. but Not sure how to integrate with my moodle. 


For PHPsolr  are there any specific instructions to install except to drag the specific compiled dll to the ext folder or something else. I have checked the PHP info page and could not see the solr enabled. please let me know I'm stuck here. 


Please consider as mine is a WINDOWS server 2012 IIS7


when i looked at the php error log it says


PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\PHP\v5.6\ext\php_Solr.dll' - %1 is not a valid Win32 application.


when i tried to install from php_solr-2.4.0-5.6-ts-vc11-x86 


PHP Startup: Unable to load dynamic library 'C:\Program Files (x86)\PHP\v5.6\ext\php_solr.dll' - The specified module could not be found.

Please help .
 
Average of ratings: -
Picture of Ken Task
Re: Installing Solr for Global Search in Moodle
Particularly helpful Moodlers

@all in this thread ...

Installing Solr Search ... Moodle 3.1.x - CentOS 6 stock ... nothing special - below is also attached as a text file for easy copy and paste into terminal.  Just stepped through this on a VB CentOS 6 ... Moodle 3.1 ...

selinux is set to permissive

As root user

yum install java-1.8.0-openjdk.x86_64

yum install curl-devel

yum install libxml2-devel

pear install pecl/solr

chmod 755 /usr/lib64/php/modules/solr.so

nano /etc/php.d/solr.ini
* insert into above file: extension=solr.so

java -version

cd /root

wget http://apache.org/dist/lucene/solr/5.5.4/solr-5.5.4.tgz

tar zxvf solr-5.5.4.tgz

mv solr-5.5.4 /opt/solr/

cd /opt/solr

cp README.txt /var/www/html/solrreadme.txt
* you can now use http://site/solrreadme.txt to read the readme while
still working in the terminal window/scree

php -m |grep solr
* to check if solr is known to PHP - command will show only 'solr'

service httpd restart

* still in /opt/solr/

bin/solr start

bin/solr create -c moodle

* above command looks strange but execute them from /opt/solr/ or they
won't work.

cd /etc/sysconfig

nano iptables

* duplicate the ssh line and on the duplicated line change port 22 to 8983 and the note that the line is for solr rather than ssh

/sbin/service iptables restart

yum install nmap

nmap -P0 -p 8983 [IPaddressofserver]

* nmap should show port 8983 open and not closed or filtered

You should now be able to use browser to go to:
http://IPADDRESS:8983/solr/
and see the admin panel of Solr
The Moodle index should be there.

Now config Moodle's solr search.

Admin menu -> Plugins -> Search -> then both Manage global search
Step through the 'Steps' in order shown.

Eventually everything should show green.

also, should setup a start script for solr so that it starts upon
reboot of server.

Create a startup script in /etc/init.d/ called solr

Contents of /etc/init.d/solr

---- start below -----------
PIDFILE=/var/run/solr.pid
SOLR_HOME=/opt/solr
START_COMMAND="$SOLR_HOME/bin/solr start -p 8983 -noprompt -m 1g"
NAME="Solr"


start() {
  echo  "Starting $NAME"
  if [ -f $PIDFILE ]; then
    echo -n "$PIDFILE exists. $NAME may be running."
  else
    str=`$START_COMMAND`
    pid=`echo $str | grep -o "pid=[0-9]*" | grep -o "[0-9]*"`
    if [ "$pid" == "" ];
    then
      echo "[FATAL ERROR] Failed to extract pid. Exiting!"
      exit 1
    fi
    echo $pid > $PIDFILE
  fi
  return 0
}


case "$1" in
  start)
    start
  ;;
  stop)
    echo "Stopping $NAME .."
    $SOLR_HOME/bin/solr stop
    rm -f $PIDFILE
  ;;
  status)
    $SOLR_HOME/bin/solr status
  ;;
  restart)
    $0 stop
    #sleep 2
    $0 start
  ;;

  *)
    echo "Usage: $0 (start | stop | restart | status)"
    exit 1
    ;;

esac
exit $?

---- end init.d/solr

To set ... after above file is in place and saved.

chmod ugo+x solr (make it executable)

/sbin/chkconfig --add solr

Test the script:

/etc/init.d/solr status

/etc/init.d/solr restart

See for yourself:

ps aux |grep java

Consider installing Webmin to help admin the server.
Webmin is an open source cPanel ... based on Perl
has it's own web server run from default port 10000 but
during installation one could set it up on 8080 or other port.

To see realtime solr logs:

tail -f /opt/solr/server/logs/solr.log

'spirit of sharing', Ken

Picture of Meir Gabay
Re: Installing Solr for Global Search in Moodle
 


Hello,

I'm using -

Linux Dist: Ubuntu 14.04.5 LTS 

cat /etc/*-release

AWS (Amazong Web Services) instance: t2.micro

Web Application: Moodle 3.2.0 by Bitnami

Remote Control App: PuTTY

I followed the instructions in these sources:

  1. https://www.digitalocean.com/community/tutorials/how-to-install-solr-5-2-1-on-ubuntu-14-04
  2. https://docs.moodle.org/31/en/Global_search
  3. Ken's thread

This is what I got -


Here's how it goes -

1. Install Java (source: https://www.digitalocean.com/community/tutorials/how-to-install-solr-5-2-1-on-ubuntu-14-04)

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer *** ACCEPT Oracle's terms... Click ENTER ***

2. Install Solr (sources: Ken Task , https://docs.moodle.org/31/en/Global_search)

cd /opt
sudo wget http://apache.org/dist/lucene/solr/5.5.4/solr-5.5.4.tgz
sudo tar zxvf solr-5.5.4.tgz
sudo mv solr-5.5.4 /opt/solr/
cd /opt/solr // like Ken said - stay in this folder the whole time!
php -m | grep solr // Good output = solr, PHP recognizes solr
// create solr.ini files in relevant folders sudo sh -c "echo 'extension=solr.so' > /etc/php5/apache2/conf.d/solr.ini" sudo sh -c "echo 'extension=solr.so' > /etc/php5/cli/conf.d/solr.ini"
sudo service bitnami apache restart // same as restart httpd
bin/solr start
bin/solr create -c moodle

3. AWS - add IP to Security Group of your instance, make it a Custom TCP Rule and port 8983 - 


4. Navigate in your browser to your 'moodle' core in Solr Dashboard - http://myserverip:8983/solr - hopefully it'll work


5. Setup Solr in Moodle using the path below ...




I also added the following line to the end of file /opt/bitnami/php/etc/php.ini though I'm not sure it's mandatory.

extension=solr.so


@Ken - feel free to comment, your thread helped me a lot


Regards,

Meir

Picture of Meir Gabay
Re: Installing Solr for Global Search in Moodle
 

Change "apache restart" to "restart apache"

sudo service bitnami restart apache // same as restart httpd


Solr.so path - AWS EC2 Moodle By Bitnami

Make sure the path in solr.ini is - /opt/bitnami/php/lib/php/extensions/solr.so

sudo sh -c "echo '/opt/bitnami/php/lib/php/extensions/solr.so' > /etc/php5/apache2/conf.d/solr.ini"
sudo sh -c "echo '/opt/bitnami/php/lib/php/extensions/solr.so' > /etc/php5/cli/conf.d/solr.ini"

php.ini add solr

You should add "extension=solr.so" to /opt/bitnami/php/etc/php.ini 

 
Average of ratings: -
Picture of Abdul Ghaffar
Re: Installing Solr for Global Search in Moodle
 

Have any one solved original problem?, for windows, getting "PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_solr.dll' - The specified module could not be found. in Unknown on line 0"

 
Average of ratings: -
Picture of Ken Task
Re: Installing Solr for Global Search in Moodle
Particularly helpful Moodlers

Assuming Windows PHP does the same as linux, you need to check the 'extra' directory that PHP will use to load extensions to php.   You should see .ini files there for those extensions.

On a linux system that 'extra' diretory is /etc/php.d/ and in that directory there is a solr.ini file.   It consist of one line (your error says line 0 ... that is the first line).

On linux, solr.ini file has:

extension=solr.so

Suggest you open any other .ini file in there to see what it shows in Windows.

Don't run Windows myself .... so this is an educated guess.

'spirit of sharing', Ken

 
Average of ratings: -