# TCExam :: Installation

## Index

- Framework
- Minimum Requirements
- Operating System Configuration
- TCExam Installation
  - Automatic Installation
  - Manual Installation
    - Configuration Files Personalization
    - Database Installation
  - Post installation
- System Configuration
- Access and Security

## Framework

TCExam is composed by three main parts:

- The Database where data are stored in records and tables.
- The TCExam software as files hierarchically organized in folders and sub-folders.
- The users, all the people that access the system, both administrators and basic users.

The database and the TCExam system files can be located in one or more internet/intranet servers, and the users can access the system with a normal web browser via the internet/intranet connection.

## File System

For of a more secure and rational structure, the TCExam program files are located in three different areas:

### admin

includes the administration area of the system.
Only the administrators can access this area.

folder | description
--- | ---
code | contains the program files of the administration area
config | contains the configuration files of the administration area
doc | contains the documentation and the licences
log | contains the log files of the administration area
styles | contains the CSS style sheets for the administration area

### shared

Contains the resources shared between the administration system (admin) and the public site (public).

folder | description
--- | ---
barcode | contains a third-part application to generate bar codes
code | contains the shared program files (main functions of TCExam)
config | contains the general configuration files
jscripts | contains shared javascript programs
pdf | contains a third-part library to generate PDF documents
phpmailer | contains a third-part library for sending emails

### public

Contains the resources accessible by the basic users.

folder | description
--- | ---
code | contains the program files of the public area
config | contains the configuration files of the public area
log | contains the log files of the public area
styles | contains the CSS style sheets of the public area

### other folders

folder | description
--- | ---
cache | contains the temporary files and the images transferred by the upload module
fonts | contains the PDF fonts
images | contains the images used by the system
install | contains the installation files of TCExam. For security reasons it is advisable to delete this folder after the installation.

## Notes

- The structure and the names of the folders can be modified according to the guidelines of this configuration file: /shared/tce_paths.php.

[index]

## Minimum Requirements

Before installing TCExam it is advisable to check the the system minimum requirements:

- A web server (e.g.: Apache [http://httpd.apache.org/], Microsoft® IIS [http://www.microsoft.com]).
- PHP 5 (http://www.php.net) - required
- The following libraries:
  - PHP GD Library 2.0.1 (http://www.boutell.com/gd) - required for true color images and plots
    This library will be installed with:
    - libpng 1.2.2 - PNG immages support
    - jpegsrc.v6b - JPEG images support
- One of the following databases:
  - MySQL 4.1+ (http://www.mysql.com)
    - Please check the following link if you experienced authentication problems: http://dev.mysql.com/doc/mysql/en/Old_client.html
  - PostgreSQL 8+ (http://www.postgresql.org)
- At least 20MB for the program files and 10MB for the database

For help with the installation and configuration of the web server and the required libraries please refer to the specific manuals.
The clients need to be equipped with a common web browser with XHTML 1.0 and JavaScript 1.2 support.
[index]

## Operating system configuration

For the correct use of TCExam, PHP has to be configured to support the systems and libraries indicated above; Some parameters of PHP must also be set like this:
on php.ini

- arg_separator.output = "&amp;"
- magic_quotes_gpc = On
- magic_quotes_runtime = Off
- magic_quotes_sybase = Off

or in the Apache module (/etc/httpd/conf/httpd.conf):

    <IfModule mod_php5.c>
    	php_value arg_separator.output "&amp;"
    	php_value magic_quotes_gpc On
    	php_value magic_quotes_runtime Off
    	php_value magic_quotes_sybase Off
    </IfModule>

To configure other general aspects of PHP or for other configuration modes, please refer to the offical guide and additional information in the www.php.net.
website
It is also necessary to assure that the disc quota of the different users are appropriate to manage all the files and the database.
NOTE:If you are using IIS in a non-Server version of Microsoft Windows, use the Microsoft application MetaEdit 2.2 to modify the maximum number of allowed simultaneous connections and the IIS timeout:

- LM/W3SVC/MaxConnections 40
- LM/W3SVC/CGITimeout 300
- LM/W3SVC/ROOT/CGITimeout 300

Note: 300 indicates the number of seconds in 5 minutes.
[index]

## Installation

Verify that the operating system is correctly installed and configured as described in the sections above.
Copy the whole content of the TCExam folder into the root of your web server or in one of its subfolders.
I you are using FTP to transfer the encoded version of TCExam, be sure to set the transfer mode to binary before sending the files to the server.
At this point you can proceed in two ways:

### Automatic Installation

This type of installation will automatically install the database and will configure the main system parameters.
Be sure to modify the access permission of the following files and folders so that the software can write into them (chmod 666 su sistemi unix-like):

- install/
- shared/config/cp_db_config.php
- shared/config/cp_paths.php

You can reset the permissions of these files to read-only at the end of the installation process.
In the eventuality that the installation program cannot modify these files, it will always be possible to modify them manually as indicated in the following section.
By using a common web browser (internet navigation software like Microsoft® Internet Explorer, Mozilla o Netscape®) go to the address where the TCExam installation program is located: http://<host>/install/install.php
If the operating environment is configured correctly, you should be able to see the installation module of TCExam.
Note that:
Due to the critical importance of this component, the installation program is provided only in english.
The installation process will delete any data of previous installations of TCExam, reason why in this case it is advisable to make backup copy of these data. To start the installation you must fill up the form completely and press the button INSTALL.
It follows a list of the fields required by the installation module:

- db type: type of database utilized (the default is MySQL)
- db host: name of the database host (usually localhost
- db port: database port (usually 3306 for MySQL or 5432 for PostgreSQL)
- db user: name of the database user (usually it is root)
- db password: user password to access the database
- db name: nome of the database (usually TCExam). This name has to be changed just when there are other copies of TCExam in the same system .
- tables prefix: prefix that will be added to the table names (usually tce_)
- host URL: the domain name of your site (e.g.: http://www.host.com)
- relative URL: relative path from the root of your webserver where the TCExam files are located (usually / or /<TCExam folder>/)
- TCExam path: complete path of the folder where TCExam is installed (e.g.: /usr/local/apache/htdocs/TCExam/ or c:/Inetpub/wwwroot/TCExam/)
- TCExam port: default http connection port (usually 80).

If the installation completed succesfully the system is ready for the first execution.
At this point you can remove the install folder from the server and restore the read-only permissions for the configuration files.
In case the installation did not complete succesfully you can complete it or repeat it using the manual procedure described in the next section.
[ index]

### Manual Installation

In order to manually install TCExam you must modify the configuration files and install the database.

#### Modification of the configuration files

The required files and configuration parameters for TCExam to start are:

- shared/config/cp_db_config.php
  - K_DATABASE_TYPE (database type, usually MYSQL or POSTGRESQL)
  - K_DATABASE_HOST (name of the database host, usually localhost)
  - K_DATABASE_NAME (database name, usually TCExam)
  - K_DATABASE_USER_NAME (nome of the database user, it usually is root)
  - K_DATABASE_USER_PASSWORD (password to access the database)
  - K_TABLE_PREFIX (prefix that will be added to the table names, usually tce_)
- shared/config/cp_paths.php
  - K_PATH_HOST (the domain name of your site, e.g.: http://www.host.com)
  - K_PATH_TCEXAM (relative path from the root of your webserver where the TCExam files are located, usually / or /<TCExam path>/)
  - K_PATH_MAIN (complete path to the folder where TCExam is installed, ad example: /usr/local/apache/htdocs/TCExam/ or c:/Inetpub/wwwroot/TCExam/)
  - K_STANDARD_PORT (http communication port, usually 80)

#### Database Installation

In the install folder there are all the SQL files with the structure and data of the database:

- mysql_db_structure.sql - contains the MySQL database structure
- pgsql_db_structure.sql - contains the PostgreSQL database structure
- db_data.sql - contains the default database data

If you want to change the prefix of the tables you must use a text editor with the search and replace function and perform the following substitutions:

- In the ..._db_structure.sql file substitute CREATE TABLE tce_ with CREATE TABLE yourprefix
- In the db_data.sql file substitute INSERT INTO tce_ with INSERT INTO yourprefix

To execute the SQL file you can use the database commands from the command shell of the server.
MySQL example:

    mysql
    mysql> CREATE DATABASE TCExam;
    shell> mysql TCExam < db_structure.sql
    shell> mysql TCExam < db_data.sql

In the previous example we assumed that the database name was TCExam.
As another option you can use an external database manager (e.g.: phpMyAdmin, phpPgAdmin, pgAdmin3, ...) to create the database and run the SQL files by using the specific command.
[index]

### Post installation

Once the installation is completed you must:

- delete the install folder since it is not necessary anymore and may represent a security issue for the system
- set as read-only (chmod -R 644 in unix-like systems) the permissions for the files and folders:
  - admin/config/
  - shared/config/
  - public/config/
- properly set the write permissions for the folders where TCExam will have to write (chmod -R 666):
  - admin/log
  - cache
  - images
  - public/log
- configure in detail the configuration files as described in the following section

[index]

## System Configuration

Once the automatic installation procedure is completed, TCExam should be fully functional.
It is possible to personalize some settings and basic features by modifying the following configuration files:

- shared/config/lang/ - language files
- shared/config/tce_config.php - system general configuration
- shared/config/tce_db_config.php - database configuration
- shared/config/tce_email_config.php - general configuration of the email system
- shared/config/tce_general_constants.php - general constants
- shared/config/tce_mime.php - MIME associations to file extensions
- shared/config/tce_paths.php - file and folder paths within the system
- shared/config/tce_pdf.php - configuration of the format and the headers of the PDF documents
- admin/config/tce_auth.php - access levels configuration for the administration modules
- admin/config/tce_config.php - general configuration of the administration panel
- public/config/tce_config.php - general configuration of the public area

[index]

## Access and Security

Once the installation and configuration procedures are completed, you can access the system going with you internet browser to the address http://<host>/admin/code/index.php and using the following username and password:

- nome: admin
- password: 1234

In order to protect your system and be granted with an unique personal access, remember to change the password with the module Users. With this module you can also insert your personal data and preferences.
In order to achieve a better level of security we suggest to protect the whole admin folder with a web-based user autentication system.
One of the most efficient and simple ways to protect a folder on a server Apache is to use the Htaccess autentication. For more informations refer to http://httpd.apache.org/docs/howto/htaccess.html.
If you are using a different web server refer to the specific documentation.
[index]