# Installation

- Minimum requirements
- Operative environment configuration
- AIOCP Installation
  - Automatic installation
  - Manual installation
    - Edit configuration files
    - Database installation
  - Post installation
- AIOCP configuration
- Access and Security

## Minimum requirements

Before starting installation you must check the system minimum requirements:

- A web server as Apache (http://httpd.apache.org/) or Microsoft® IIS (http://www.microsoft.com).
- MySQL 3.23.xx (http://www.mysql.com) - needed
- PHP 4.2.x (http://www.php.net) - needed
- The following libraries are already embedden on PHP 4.3.x, so they will be manually installed only for PHP early versions.
  - PHP Zlib library (http://www.gzip.org/zlib) - needed for backup
  - PHP GD Library 2.0.1 (http://www.boutell.com/gd) - needed for images and graphic in true color
    (you can also use the 1.8.x version that do not support true color)
    This library must be installed with:
    - FreeType Lybrary 2.0.1(http://www.freetype.org) - needed for graphic buttons and charts
    - libpng 1.2.2 - PNG image format support
    - jpegsrc.v6b - JPEG image format support
- Zend OptimizerTM 2.1.0 to run encoded files (not required for unencoded version).
- At least 30MB for files and 20MB for MySQL database

Please consult the respective manuals for installation and configuration of web server and libraries.

## Operative environment configuration

The PHP environment must be configured to support all systems and libraries above indicated.
Some PHP paramaters must be set as below:
on php.ini

- safe_mode = Off
- register_globals = On
- session.save_handler = user
- arg_separator.output = "&amp;"
- session.use_trans_sid = 0

alternatively on Apache module (/etc/httpd/conf/httpd.conf):

    <IfModule mod_php4.c>
    	AddIcon /icons/php4.gif .php3 .php4 .php .phtml
    	php_admin_flag safe_mode off
    	php_admin_flag register_globals on
    	php_value arg_separator.output "&amp;"
    	php_value session.save_handler user
    	php_value session.use_trans_sid 0
    </IfModule>

To configure PHP in general or for different configuration methods, please consult the official guide and annotations on www.php.net site.
Please check also the users disk quota that must be enough to handle files and database.
NOTE:If you get a CGI Timeout Error on IIS server during installation, you must change the CGI Script Timeout parameter to a bigger value (Administrative Tools -> Internet Information Services -> right click on Web Sites icon -> Properties -> Home Directory -> Configuration -> Process Options -> change CGI script timeout value to 1200 seconds).

## AIOCP Installation

Please verify that the operative environment is correctly setup as described in previous paragraphs.
Copy all content of AIOCP folder on server's web root or in a subfolder.
If you are using FTP to upload an AIOCP encoded version, please make sure to set your FTP client's transfer mode to BINARY before upload PHP files to your server.
Now it's possible to proceed in two ways:

### Automatic installation

This procedure allows you to automatically install database and configure the fundamental configuration parameters.
Please modify the following files and directories permissions in a way that could be writeable by the software (chmod 777 on unix-like systems):

- install/
- shared/config/cp_db_config.php
- shared/config/cp_paths.php
- admin/phpMyAdmin/config.inc.php

These files permissions could be restored to read-only after installation.
In case of errors, you could modify manually these files as described in next paragraph.
Using a common web browser (program used to viewing sites as Microsoft® Internet Explorer or Netscape®), go to your site where the installation program of AIOCP is located: http://<yoursite>/install/install.php
If the operative environment is setup correctly you must see the AIOCP installation module.
Note that:
The installation module is available only in english language due to it's crucial function.
This installation process will destroy any database data from previous installations. Please backup any previous installation data.
Due to large amount of data of some database tables, the installation process may take a while, so please be patient and do not interrupt the installation process until finish.
To start installation you must fill the form and push the INSTALL button.
The following are the requested fields on installation form:

- db host: MySQL database host name (normally localhost)
- db user: MySQL database user name (normally root)
- db password: MySQL database user password
- db name: database name (normally AIOCP). You must change this only for multiple installations.
- tables prefix: tables prefix (normally aiocp_)
- host URL: the domain name of your site (e.g.: http://www.mysite.com)
- relative URL: path starting from webserver root where AIOCP is located (normally / or /<path to AIOCP>/)
- AIOCP path: real full path where AIOCP is located (e.g.: /usr/local/apache/htdocs/AIOCP/ or c:/Inetpub/wwwroot/AIOCP/)
- mysql path: real full path where MySQL database data folder is located (e.g.: /var/lib/mysql/ or c:/mysql/data/). This parameter is optional and is needed only for MySQL backup.

If the installation process has been completed without errors the system is ready for it's first execution.
Now you can safely remove the install folder and restore to read-only the configurations files permissions.
In case of installation errors you could complement or repeat the installation process using the following procedure.

### Manual installation

To manually install AIOCP you must edit the configuration files and install the database.

#### Edit configuration files

The essential files and constants for AIOCP installation are:

- shared/config/cp_db_config.php
  - K_DATABASE_HOST (MySQL database host name, normally localhost)
  - K_DATABASE_NAME (database name, normally AIOCP. You must change this only for multiple installations.)
  - K_DATABASE_USER_NAME (MySQL database user name, normally root)
  - K_DATABASE_USER_PASSWORD (MySQL database user password)
  - K_TABLE_PREFIX (tables prefix normally aiocp_)
- shared/config/cp_paths.php
  - K_PATH_HOST (the domain name of your site, e.g.: http://www.mysite.com)
  - K_PATH_AIOCP (path starting from webserver root where AIOCP is located, normally / or /<path to AIOCP>/)
  - K_PATH_MAIN (real full path where AIOCP is located, e.g.: /usr/local/apache/htdocs/AIOCP/ or c:/Inetpub/wwwroot/AIOCP/)
  - K_PATH_MYSQL_DATA (real full path where MySQL database data folder is located, e.g.: /var/lib/mysql/ or c:/mysql/data/. This parameter is optional and is needed only for MySQL backup.)
- admin/phpMyAdmin/config.inc.php
  - cfg['PmaAbsoluteUri'] (url internet address where phpMyAdmin software is installed, normally http://<mysite>/admin/phpMyAdmin/)
  - cfg['Servers'][$i]['host'] (MySQL database host name, normally localhost)
  - cfg['Servers'][$i]['user'] (MySQL database user name, normally root)
  - cfg['Servers'][$i]['password'] (MySQL database user password)

#### Database installation

Inside the install folder there are two SQL files for database schema and data. These files must be used in the correct order:

- aiocp_db_structure.sql - MySQL database structure
- aiocp_db_data.sql - MySQL database data

If you wish to change the tables prefix (the default is aiocp_) you must use a text editor with search and replace tool and operate the following substitutions:

- On aiocp_db_structure.sql replace CREATE TABLE aiocp_ width CREATE TABLE yourprefix
- On aiocp_db_structure.sql replace DROP TABLE IF EXISTS aiocp_ width DROP TABLE IF EXISTS yourprefix
- On aiocp_db_data.sql replace INSERT INTO aiocp_ width INSERT INTO yourprefix

To execute these SQL files you could use the MySQL commands from server shell:

    mysql
    mysql> CREATE DATABASE AIOCP;
    shell> mysql AIOCP < aiocp_db_structure.sql
    shell> mysql AIOCP < aiocp_db_data.sql

In the example above AIOCP is the database name.
Alternatively (if you have configured the admin/phpMyAdmin/config.inc.php file) you could use the utility http://<mysite>/admin/phpMyAdmin/index.php by which you could create database ans execute SQL statements.

### Post installation

Once the installation process is completed you must:

- delete the install folder because it's no more necessary and represent a security risk for current installation.
- set to read-only (chmod -R 644 on unix-like systems) all the files on folders:
  - admin/config/
  - shared/config/
  - public/config/
- set in the right way the permissions of the folders that may be accessed in write mode by AIOCP software (chmod -R 777):
  - admin/backup
  - admin/log
  - attachments
  - banners
  - cache
  - download
  - images/avatars
  - images/awards
  - images/company
  - images/flags
  - images/icons
  - images/icons_client
  - images/levels
  - images/menu
  - images/products
  - images/products_categories
  - images/reviews
  - images/smiles
  - images/userphoto
  - pagefiles
  - public/log
  - shared/log
  - sounds
- edit configuration files details as described in next paragraph

## AIOCP configuration

After installation, AIOCP must be ready to use all of it's functions except email sending for wich you must manually edit the following file:

- shared/config/cp_email_config.php

The remaining configuration files are listed below. I suggest to NOT edit these files unless you are sure about what are you doing:

- shared/config/cp_config.php - general system configuration
- shared/config/cp_colors.php - color codes table
- shared/config/cp_db_config.php - database configuration
- shared/config/cp_ecommerce.php - e-commerce configuration (currecy, ...)
- shared/config/cp_extension.inc - system file extension (.php)
- shared/config/cp_general_constants.php - general constants
- shared/config/cp_paths.php - system path for files and directories
- admin/config/cp_config.php - general administration panel configuration
- admin/config/cp_auth.php - set user access level to administration modules
- public/config/cp_config.php - public site general configuration

To configure the e-commerce payment and shipping modules, please consult the relative documentation located on the following folders:

- shared/payment/ - payment modules
- shared/shipping/ - shipping modules

## Access and Security

Once completed the installation and configuration procedures above described, you may access to AIOCP system pointing your web browser to http://<yoursite>/admin/code/index.php and using the following data:

- name: admin
- password: 1234

To protect your site and guarantee exclusive access, please remember to change the password using the editor Users -> User Editor. This editor allows you also to set your data and preferences.
To increase the security level I strongly suggest to protect the entire admin folder using a web based user authentication system.
One of the quickest ways to secure a directory on an Apache web server is to implement Htaccess web based user authentication. For more information, please consult http://httpd.apache.org/docs/howto/htaccess.html.
If you are using a different web server please consult the relative documentation.