Skip to content

Installation

Willy Wong edited this page Sep 10, 2018 · 15 revisions

Clone the repo

git clone https://github.com/CRBS/CIL_RS.git

mv CIL_RS/CIL_RS /var/www/html

See Elasticsearch Installation

Create a configuration JSON file

  • Create a file called cil_service_config.json under /var/www or anywhere else outside of Apache root directory.
  • Make sure that Apache has the permission to access cil_service_config.json
  • Your cil_service_config.json should look like the following:
{
  "cil_service_users":[
  	{
  	   "username":"cil",
  	   "key":"YOUR_KEY_STRING",
           "can_write":true
  	}
  ],
  "cil_pgsql_db":"host=YOUR_HOST port=5432 dbname=YOUR_DB_NAME user=YOUR_USER_NAME password=YOUR_PWD",
  "cil_unit_tester":"cil:YOUR_KEY_STRING",
  "elasticsearch_host_stage":"http://YOUR_STAGING_ELASTICSEARCH_HOST:9200",
  "elasticsearch_host_prod":"http://YOUR_PRODUCTION_ELASTICSEARCH_HOST:9200"
}

Postgres DB Scripts

CREATE DATABASE cil_statistics
CREATE SEQUENCE general_sequence
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 9223372036854775807
  START 1
  CACHE 1;
CREATE TABLE cil_download_statistics
(
  id bigint NOT NULL,
  ip_address text,
  image_id text,
  url text,
  size bigint,
  download_time timestamp without time zone,
  CONSTRAINT cil_download_statistics_pk PRIMARY KEY (id)
)

Edit config.php

  • Edit application/config/config.php
$cil_config_file = "/var/www/cil_service_config.json"; //Or your own path

Edit rest.php

  • Edit application/config/rest.php
$cil_config_file = "/var/www/cil_service_config.json"; // Or your own path

Configure the Apache configuration file

  • Edit httpd.conf
  • Enable mod_rewrite
  • Your directory block should have the following:
<Directory "YOUR_HTTP_ROOT_DIRECTORY">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
    
    RewriteEngine On
    RewriteBase /
    RewriteCond $1 ^(application|system|private|logs)
    RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
    RewriteCond $1 ^(index\.php|index\.html|robots\.txt|favicon\.ico|public|assets|css|js|resources|Knowledge_Space_files|img|static|pic|pix|swf|assets|videos|template|old_cil|fonts|display_images|docs)
    RewriteRule ^(.*)$ - [PT,L] 
    RewriteRule ^(.*)$ index.php/$1 [PT,L] 
</Directory>

Configure the PHP settings

  • Edit php.ini
  • Enable php_curl
  • Enable php_pdo_pgsql
  • Set memory_limit = 1024M

Restart the Apache HTTP server

service httpd restart

Basic testing

Open a web browser and try to load http://YOUR_HOST:YOUR_PORT/rest/projects

It should prompt for the user name and password.

PHP Unit testing

Download the PHP unit test toolkit at https://phpunit.de/

cd CIL_RS/CIL_RS/test

Edit TestService.php and set $elasticsearchHost to your testing server.

RUN:

phpunit-6.1.4.phar TestService.php

Clone this wiki locally