Note: The installer for the latest version is broken, so this guide takes you through installing v1.7.2 and updating.

IceBear install instructions - LAMP server already running
==========================================================

IceBear storage (for images, file uploads, etc.)
------------------------------------------------
By default this is /icebearstore. You'll need this directory later in the installation process.

> mkdir /icebearstore/
> chown www-data /icebearstore/

IceBear backups directory
-------------------------
If you're not backing up IceBear some other way, it can back itself up to a specified directory. By default,
this is /icebearbackups. You'll need this directory later in the installation process.

> mkdir /icebearstore/
> chown www-data /icebearstore/

IceBear logs
------------
> mkdir /var/log/icebear/
> chown www-data /var/log/icebear/

CIFS utils
----------
Needed for mounting Windows SMB shares - like the Formulatrix image store
> apt-get --assume-yes install cifs-utils

PHP extensions
--------------
Install sybase, gd, curl extensions 

> apt-get --assume-yes install php{PHPVERSION}-sybase
> apt-get --assume-yes install php{PHPVERSION}-gd
> apt-get --assume-yes install php{PHPVERSION}-curl


PHP configuration
-----------------
In both cli and apache php.ini files (/etc/php/{PHPVERSION}/cli/php.ini and /etc/php/{PHPVERSION}/apache2/php.ini), 
set the post_max_size to at least 8 megabytes, and mssql.secure_connection to on:

post_max_size = 8M
mssql.secure_connection = on


Apache vhost
------------
Create and enable a new Apache vhost for IceBear
For that vhost:
- enable mod_rewrite
- set AllowOverride to All


IceBear files
-------------
Download IceBear and unpack to the new vhost's wwwroot
> wget https://www.icebear.fi/releases/icebear_v1_7_2.tar
> tar -xf icebear_v1_7_2.tar -C {wwwRoot}


Restart Apache
--------------
Recognises new vhost, PHP extensions and config


Test vhost
----------
Visit the new vhost in your browser. You should see an error about the pre-installation script not having been run.


IceBear config file:
--------------------
> cp {wwwRoot}/conf/config.ini.example {wwwRoot}/conf/config.ini
Edit {wwwRoot}/conf/config.ini with your intended database credentials. dbType must be mysql.


IceBear database
----------------
This creates the tables for a 1.0 database; the installer will later modify this to match the IceBear version you're installing.

> mysql -e "CREATE USER '{DbUser}'@'localhost' IDENTIFIED BY '{DbPass}';"
> mysql -e "CREATE DATABASE IF NOT EXISTS {DbName} DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;"
> mysql -e "GRANT INSERT,DELETE,SELECT,UPDATE,CREATE,DROP,INDEX,ALTER,CREATE TEMPORARY TABLES,CREATE VIEW,TRIGGER,SHOW VIEW,EVENT,CREATE ROUTINE,ALTER ROUTINE,EXECUTE,REFERENCES ON {DbName}.* TO '{DbUser}'@'{DbHost}';"
> mysql -e "FLUSH PRIVILEGES;"
> mysql --database {dbName} < {wwwRoot}/install/icebeardatabase.sql


Temporary cron
--------------
The installer will write a shell script to be run by root at the end of installation; this takes care of adding Formulatrix drives to /etc/fstab, etc.
Add the following line to root's cron; it will be removed at the end of the installation.

* * * * * {wwwRoot}/install/rootinstalltasks.sh


Finishing up the pre-install
----------------------------
Ensure that everything in wwwRoot is owned by the Apache user, and set a flag for the web installer.

> chown -R www-data {wwwRoot}
> touch {wwwRoot}/install/preInstallDone


Web installer
-------------
Continue the installation process through the web interface; visit the new IceBear vhost in your web browser.

Update to latest version
------------------------
Log into IceBear with your newly-created admin username and password.
From the main menu (at top right), select Configuration.
Select the "IceBear version" tab. You should see a list of newer versions.
Click "Update" on the latest version.

