Casebox HowTo

How to create a new Casebox core

use CB/bin/create_core.php script or do manualy:

  1. create mysql database for new core (cb_[core] , with charset utf8, collation utf8_general_ci) and copy contents from another core. (cb_demo for ex.)
  2. Clear log, users, update root password, etc
  3. update root password
  4. If you're cloning a core: copy files structure from original core to new core if needed (files are located at /var/www/casebox/data/files/[core]/ )
  5. use SolrAdminAPI to create a new SOLR core
  6. Run the script from /CB/bin/ to reindex all data in solr: php -f solr_reindex_core.php -c coreName -a -l)
Note: if the core has custom code, create the core folder in /var/www/casebox/httpsdocs/cores/[core]/, and copy the configs/code/css from the existing core you're cloning.

Create a SOLR core using a configSet

This command will create a new SOLR core named cb_mycore based on cb_default configSet. This command creates the folder /var/solr/data/cb_mycore and the core.properties file.

> curl http://localhost:8983/solr/admin/cores?action=CREATE'&'name=cb_mycore'&'configSet=cb_default

Notice that '&' is quoted to make curl work

Usually you'll use CB/bin/create_core.php and the above will be performed for you.

Create a SOLR core using a custom schema

CB_core related files are located in /CB/httpsdocs/cores/[core], create the folder if it doesn't exists yet. Your custom SOLR schema should be added to solr subfolder (created by the instructions below).

# Copy solrconfig.xml
# from: /CB/sys/solr_configsets/default_config/conf/
# to: /CB/httpsdocs/cores/[core]
> cp /var/www/html/casebox/sys/solr_configsets/default_config/conf/solrconfig.xml /var/www/html/casebox/httpsdocs/cores/[core]/solr/solrconfig.xml


# Copy (or use your own) stopwords.txt
# from: /CB/sys/solr_configsets/default_config/conf/
# to: /CB/httpsdocs/cores/[core]
> cp /var/www/html/casebox/sys/solr_configsets/default_config/conf/stopwords.txt /var/www/html/casebox/httpsdocs/cores/[core]/solr/stopwords.txt

# Create symlink to CB SOLR configs
> ln -s /var/www/html/casebox/sys/solr_configsets/default_config /var/www/html/casebox/httpsdocs/cores/[core]/solr/cb_default

# Create 'core' folder in SOLR
> mkdir /var/solr/data/cb_[core]
> chown solr:solr /var/solr/data/cb_[core]

# create symlink to custom SOLR config
> ln -s /var/www/html/casebox/httpsdocs/cores/[core]/solr /var/solr/data/cb_[core]/conf

# use SOLR CoreAdminAPI to create the core
> curl http://localhost:8983/solr/admin/cores?action=CREATE'&'name=cb_[core]

# ok, now cb_[core] SOLR core is ready

For Windows, symlinks are created as follows:

mklink /J c:/var/www/casebox/httpsdocs/cores/[core]/solr/cb_default c:/var/www/casebox/sys/solr_configsets/default_config

mklink /J c:/var/solr/data/cb_[core]/conf e:/var/www/casebox/httpsdocs/cores/[core]/solr

Deleting a SOLR core

To delete a SOLR core and all data:

curl http://localhost:8983/solr/admin/cores?action=UNLOAD'&'core=cb_corename'&'deleteInstanceDir=true

SOLR Reindexing

Modified records in MySql database will be indexed in SOLR. If you need to reindex a core (you've moved it to another server and SOLR core is empty, or SOLR has been upgraded and full reindex is required) you need to call this script:

> php -f /var/www/casebox/bin/solr_reindex_core.php -c demo -a -l

-a: mark all records to be reindexed.
-l: means no-limit. By default, up to 500 records are indexed in SOLR when you run the script. Specify -l to remove this limit. Notice: you might get an "Out of memory" error, just run the script again (but without -a of course).

solr_reindex_core.php script is used to index MySql database into SOLR core. If -a parameter is specified, CB will only mark all records to be reindexed. -l parameter means that CB should attempt to reindex as much as possible (no limits). If the database is huge, you might get an "Out of memory error". Just launch reindexing again (but without "-a" as it will mark all records again).


Quick&Dirty way to delete many records

To test a script that imports thousands of records, you'd need to clean up the database before doing another import. Instead of restoring an empty dump of the database for each import test (and having to reindex all the data in SOLR), you can delete the records from MySql and SOLR:

MySql > DELETE FROM objects WHERE id IN (SELECT id FROM tree WHERE template_id=100) > DELETE FROM tree WHERE template_id=100 SOLR

How to install prerequisites on CentOS

Install PHP, Apache from REMI56 repository:

> yum –enablerepo=remi,remi-php56 update -y

Install ImageMagick & imagick.

> yum install make
> yum install gcc
> yum --enablerepo=remi,remi-php56 install php-fpm php-devel php-pear
> yum install ImageMagick ImageMagick-devel
> pecl install imagick
> echo "extension=imagick.so" > /etc/php.d/imagick.ini

Install dependencies to run phpUnitTests

Make sure you have these installed:

  • php5-readline
  • php5-phar
  • php5-curl
  • php5-openssl
  • php5-mbstring

For code coverage to run, xdebug is required, see this article for example Installing Xdebug on CentOS


Serverside actions to perform after a git pull (i.e. after a new CB version)

  1. if there were js changes - clear /data/tmp/minify folder
  2. if there were translations updates - run /bin/languages_update_js_files.php
  3. it there are database change - run differential sql files
  4. sessions table could be truncated to force reloading of client interfaces
Copyright (C) KETSE, HURIDOCS