Software engineer, data guy, Open Source enthusiast, New Hampshire resident, husband, father. Fan of guitars, hiking, photography, homebrewing, sarcasm.
Drupal 7: Creating a Centos server installation for Apache, MySQL, Tomcat, PHP, Drupal, and Solr
In this article I’ll show the commands I have been using to set up a fresh Centos server, configured for Apache, MySQL, PHP, Tomcat, Drupal, and Apache Solr. For my article, I used Parallels to create a virtual machine from the Centos 5.6 64bit ISOs I downloaded. To simply this article, all commands are being executed as root, firewall configurations and performance tweaks are not accounted for.
Once the distribution is installed, the first thing I do is upgrade all packages.
Install PHP, Apache, and MySQL
Set runlevels for Apache and MySQL
Install subversion. I chose to use subversion for this article because the Drupal 6 installation works well with svn:externals to fetch the SolrPhpClient library. All subversion commands are connecting to a local subversion repository. If you are using an external server (like Beanstalk), you will have to transpose all commands from using “file://” to “https://”.
Add a new local subversion repository (OPTIONAL).
Download/setup drush
Create a vhost location on the server for the Drupal installation.
Integrate the Drupal files with subversion
Download the Drupal apachesolr module
Setup MySQL
Setup Apache vhost
Reset Apache file permissions. NOTE: you will need a more solid/secure configuration for this!
Start Apache
Install Drupal via drush
At this point, you should be able to browse to your site and it will be up and running.
Now we move onto Tomcat and Solr.
Installing Tomcat and Java. The default Centos yum repositories provide Tomcat5. I prefer Tomcat6, so there are some extras steps below and a dependency issue I had to resolve.
At this point, you should be able to access Tomcat in your browser (http://example.com:8080)
Downloading Solr Java library.
Copying the java war file into the Tomcat webapps folder will create this directory automatically:
Create Catalina config file to link war file to solr directory:
Setup Tomcat admin user(s):
Update WEB-INF/web.xml file:
Copy conf files from Drupal apachesolr module into Tomcat Solr conf directory (overwrite):
Reset Tomcat permissions/ownership:
Restart Tomcat
At this point, you should be able to access the solr/admin tomcat Page (http://example.com:8080/solr/admin)
If things are not working well at this point, check the Tomcat logs:
And, ensure the solr java module is listed in the Tomcat Web Application Manager: http://example.com:8080/manager/html
If all is well, you can now enable the Drupal apachesolr modules:
Log into your Drupal site. NOTE: default account (via drush): admin/admin
Edit default Apache Solr Host Settings:
URL: http://example.com/admin/config/search/apachesolr/server/solr/edit
Change url to: http://example.com:8080/solr, and save form.
Go to Drupal search settings page:
URL: http://example.com/admin/config/search/settings
Change the default search mode to “Apache Solr search”, and save form.
Now, you are ready to test the indexing and integration.
Add a new piece of content to test indexing.
Browse to solr index page:
URL: http://example.com/admin/config/search/apachesolr/index
Select: Index queued content, and click on Begin button
You should see a status message like: “1 item processed successfully.” and “Number of documents in index: 0 (1 sent but not yet processed)”
A few minutes later, refreshing the index page should show: “Number of documents in index: 1”
Search for “test” to verify Solr results.
URL: http://example.com/search/site/test
You can also review search results via solr/admin
URL: http://example.com:8080/solr/admin/
Enter “test” in query string box and click search
Part 2, Multicore Configuration (OPTIONAL)
If you need to run multiple sites off a single Solr Tomcat installation, you can setup multicore..
Copy the multicore xml file into your solr directory:
Create a new directory for each multisite in the solr directory:
Replicate the solr conf directory into the new multisite directory:
Update the solr.xml file:
Restart Tomcat
Now your new multicore site will be accessible here: http://example.com:8080/solr/example.com/admin/