I tried looking for documentation but it is quite sparse. I wrote the following guide hoping that it might save someone 2-3 hours dealing with installations, setup and configuration.
The performance gains from using Solr are quite spectacular compared to the MySQL fulltext search standard setup. It is definitely worth the time to get this working in your Magento installation.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Magento - Solr Installation & Configuration
- Make sure the Java JDK is installed:
- sudo add-apt-repository ppa:sun-java-community-team/sun-java6
- sudo apt-get update
- sudo apt-get install sun-java6-jre sun-java6-jdk
Install & Configure Tomcat:
- Installation:
sudo apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user - Configuration:
vi /etc/tomcat6/tomcat-users.xml Add the following roles and user to the configuration.
<role rolename="admin"/> <role rolename="manager"/> <user username="tomcat" password="password" roles="admin,manager"/>
Restart the server: /etc/init.d/tomcat6 restart
If all goes well, goto http://hostname:8080
- Installation:
Install Solr:
- Check for the latest distro here.. http://apache.rediris.es/lucene/solr/
- Download release http://apache.rediris.es/lucene/solr/3.3.0/apache-solr-3.3.0.zip
Install & Configure
- unzip apache-solr-3.3.0.zip
- mkdir /usr/share/tomcat6/webapps
- cp apache-solr-3.3.0/dist/apache-solr-3.3.0.war /usr/share/tomcat6/webapps/solr.war
- cp -r apache-solr-3.3.0/example/solr /usr/share/tomcat6/solr
vi /etc/tomcat6/Catalina/localhost/solr.xml
<Context docBase="/usr/share/tomcat6/webapps/solr.war" debug="0" privileged="true" allowLinking="true" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/usr/share/tomcat6/solr" override="true" /> </Context>
- chown -r tomcat6.tomcat6 /var/lib/tomcat6
- /etc/init.d/tomcat6 restart
You should see Solr access on your Tomcat admin/manager page (http://hostname:8080/manager/html)
Configure Magento to use Solr:
Replace the original Solr conf directory with the Magento conf files. The trick is just to copy the directory from Magento, and replace the one in Solr. That's it!
- In Magento, the folder is located in: [magento-instance-root]/lib/Apache/Solr/conf.
- In Solr, the folder is located in [Solr-instance-root]/example/solr/conf.
- Configure Solr in Magento: In admin, goto System -> Configuration -> Catalog -> Catalog Search
Troubleshooting:
Make sure all configuration files belong to tomcat6:tomcat6
chown -r tomcat6.tomcat6 ...
- /var/lib/tomcat6/conf/Catalina/localhost
- /usr/share/tomcat6/solr/conf