Sauf indiqué, cette procédure prends en compte par défaut les distributions GNU/Linux Ubuntu et Debian


# Paquets nécessaires:

##  Ubuntu Trusty
```
apt-get install python-software-properties php5 php5-gd php5-imagick php5-xdebug php-pear php5-mysqlnd php5-xhprof graphviz apache2 mysql-server libapache2-mod-php5 git php5-mcrypt php5-curl yaz
```

## Debian Wheezy-Jessie
```
apt-get install php5 php5-gd php5-imagick php5-xdebug php-pear php5-mysqlnd graphviz apache2 mysql-server libapache2-mod-php5 git php5-mcrypt php5-curl yaz php5-xhprof

```
## ArchLinux
```
yaourt -S php php-gd php-imagick xdebug php-pear apache mariadb php-apache php-xhprof graphviz git php-mcrypt binutils automake autoconf gcc make fakeroot
```

## CentOS
```
rpm -Uvh http://repo.webtatic.com/yum/el6/latest.rpm
yum install php54w php54w-gd php54w-pear php54w-mysql php54w-pecl-xdebug php54w-xml php54w-soap php54w-mbstring
```

Il est nécessaire de compiler Imagick extension à partir des sources.


# Installer PHPUnit (en compte root / sudo):
Rechercher le numéro de la dernière version *phpunit-x.x.x.phar* sur [https://phar.phpunit.de](https://phar.phpunit.de)

```
  cd /usr/local/bin
  wget https://phar.phpunit.de/phpunit-x.x.x.phar
  mv phpunit-x.x.x.phar phpunit
  chmod +x phpunit
```

# Récupération des sources
```
cd /var/www
git clone http://git.afi-sa.fr/afi/opacce.git opacce
```

Lancer le script update.sh

```
cd opacce
./update.sh
```



# Configuration Apache / PHP:

## Activez les modules :

### Debian
```
a2enmod headers rewrite php5
```
### ArchLinux:

Modifiez /etc/httpd/conf/http.conf et ajoutez la ligne: 

```
LoadModule php5_module modules/libphp5.so
```

Activer mod_mpm_prefork (voir https://wiki.archlinux.org/index.php/Apache_HTTP_Server#PHP).


Désactivez le module negotiation qui pose problème avec Zend Framework sur les urls index/index:

```  
a2dismod negotiation
```

## Configurer PHP

Dans /etc/php5/apache2/php.ini (ArchLinux: /etc/php/php.ini), configurer les variables suivantes:
```
post_max_size = 10M
upload_max_filesize = 10M
error_reporting  =  E_ALL & ~E_NOTICE & ~E_DEPRECATED
extension = xhprof.so
xhprof.output_dir = /chemin/vers/bokeh/temp
```

Activez les extensions suivantes si elles ne le sont pas déjà (elles devraient l'être) : 
```
php5enmod calendar curl gd gettext iconv mcrypt mysql pdo_mysql openssl soap imagick
```

Sur ArchLinux décommenter les lignes correspondantes.

## Configurer Apache

Dans la conf Apache (/etc/apache2/sites-available/votre-site.conf), supprimer l'option Indexes (listing des fichiers) et autoriser les .htaccess: 

```
<Directory /var/www/>
  Options FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>
```

Note: pour apache 2.4

```
<Directory /var/www/>
  Options FollowSymLinks
  AllowOverride All
  Require all granted
</Directory>
```


# Droits sur le répertoire temporaire

```
chmod -R 777 opacce/temp
```

# Configuration MySQL
  
## Finaliser l'installation (ArchLinux)

Voir https://wiki.archlinux.org/index.php/MySQL#Installation


## Configuration

Modifier /etc/mysql/my.cnf pour forcer l'indexation fulltext à partir de 1 lettre : ajouter dans la section [mysqld] :

```
ft_min_word_len = 1
```
Redémarrer mysql.


Notes: si des problèmes d'encodage de caractères sont visibles dans Cosmogramme, il est possible de forcer l'UTF8 comme ceci:

```
skip-character-set-client-handshake
character-set-server=utf8
```

Se connecter à mysql et importer le schema

```
mysql -uroot -ppass
mysql> create database opac;
mysql> connect opac;
mysql> source opacce/scripts/opac2.sql;
```

# Configuration OPAC
  
Dans le répertoire opacce, copiez et configurez

```
cp config.ini.default config.ini
touch local.php
```

# Configuration Cosmogramme
  
  Dans le répertoire cosmogramme, copiez et configurez

```
cp config.ref.php config.php 
```

  Allez sur http://localhost/opacce/cosmogramme

  

# Mise à jour de la base de données

En ligne de commande:
```
php scripts/upgrade_db.php
```

ou bien via navigateur web:
- Pointez votre navigateur sur http://localhost/opacce/cosmogramme/ et connectez vous avec le compte admin / achanger.
- De là, cliquez sur le lien **Vous devez exécuter une mise à niveau de la base de données**.



# Se connecter à l'OPAC:

Vous pouvez maintenant administrer Bokeh à l'adresse http://localhost/opacce/admin avec le compte admin / achanger.

Les URLs sont:
- interface publique: http://localhost/opacce
- interface d'administration: http://localhost/opacce/admin
- interface de configuration des intégrations SIGB: http://localhost/opacce/cosmogramme


# Pour lancer les tests de l'OPAC:
```
cd opacce/tests/
phpunit
```