WEB-ERP Installation

/* $Revision: 1.19 $ */

Upgrading

A php upgrade script is provided for versions from 3.05 that applies the database changes required to move from the previous version to the newer version - this script also updates any data as required to work with the new version scripts. Simply point your browser to Z_Upgrade3.06-3.07.php (for an upgrade between 3.06 and 3.07 - similar naming convention applies to subsequent releases) and follow the prompts. If you are upgrading through several versions eg. from 3.05 to 3.08 then you must run each successive Z_UpgradeX.XX-X.XY.php script in sequence.

If the database must be updated manually (as it must for versions prior to 3.05), the SQL scripts are included under webERP/sql/mysql/ to update an existing mysql webERP database to the current version. The upgrade script no longer assumes the weberp database is called webERP. If using the mysql command line client then each upgrade SQL script must be edited to enter the name of the database to upgrade by adding a line

USE mydatabase;

at the beginning of the script. Where mydatabase is the name of the company database that you are using in your webERP installation.

It is recommended not to use phpMyAdmin to run the upgrade script since you select the database to use using the web GUI and you can click on the import tab and select the upgrade script to run against the DB more easily. 

If you are running the upgrade script with the mysql command line client, after editing the script as described above the syntax to use is as follows:

mysql --user=weberp_db_user --password='some_pass' < /webERP/sql/upgradescriptname.sql

where weberp_db_user is the name of your mysql user and some_pass is the password for that user.


If you have some modified scripts that you require these should be saved in a separate directory for the purposes of reworking against the new scripts. 
The old version scripts should be deleted and the new scripts extracted to the webERP installation directory under the web-server root directory. config.php will require modification for your database username and password and company specific details.



***************New Installations***************

Note: It is worth printing this document off and checking off the steps as you go.

Pre-requisites:

- A working PHP web server - v 4.3 or later - with support for mysql or postgres databases, gd, gettext and ftp
- A working MySQL or Postgres server (MySql version 4.1 or above - innodb tables must be enabled - this normally requires modifying your my.cnf file (normally under /etc/my.cnf or the mysql data directory - see the MySQL manual).

Installing these components are well covered elsewhere - but if you need to install these components the recommended solution under windows would be to download and install apache2triad - http://apache2triad.net/ or under windows or *nix download and install XAMP - http://www.apachefriends.org/en/xampp.html

PHP must have the register globals configuration parameter set to off.  This is the default (now).  This flag can be set in the php.ini on the server.  If it can't be changed, it is possibe for apache web servers to create a file called .htaccess. A .htaccess file is included in the webERP directory that ensures the register_globals flag is set to off for those web-servers that support .htaccess files.

In addition the magic_quote_gpc setting must also be set to off. This is a configuration parameter in the php.ini file on the web-server. If you don't have access to the web-server's php.ini, then the webERP distribution has an .htaccess file to ensure that this is set to off for apache servers and thos other servers that look at the parameters in the .htaccess file. If magic_quotes_gpc is not set to off then this can leave annoying "\" characters in some fields otherwise webERP works as normal.

One more issue with php setup - by default the setting session.use_cookies is set to 1, if it is set to 0 this can also cause problems.

There are a number of traps with PHP installation depending on the web-server - see http://www.weberp.org/wikidocs/FrequentlyAskedQuestionsInstallation

The system is developed using MySQL. webERP was also tested up to version 3.05 with the Postgres database server. Postgres is no longer supported due to lack of support for testing with postgres and writing upgrade scripts. Instructions here are for mysql.

The installation consists of:

1. Copying all the PHP scripts and include files to a directory under the web server root directory
2. Creating the database and populating with initial data
3. Editing config.php for the database connection information and any other requirements
4. Logging into the system for the first time
5. Setting up system parameters and company specific information in the system.

1.  Copying all the PHP Scripts to the correct directory

You must have downloaded the archive to be reading this file INSTALL.txt file!
However, all files in this archive should be copied to a directory under the web server root directory. This varies between installations but

In Windows it could be:

C:\Program Files\Apache Group\Apache\htdocs

or for apache2triad installations:

C:\apache2triad\htdocs\

Under Linux something like:

/usr/local/httpd/htdocs/

or

/usr/local/apache2/htdocs/

or

/srv/www/htdocs

Normally the Apache document root directory is called "htdocs". However other web-servers can be used and their document root directory names will vary.

Under windows use winzip (or XP/Vista's native abilites) to extract the archive under the web server root directory.

Under *nix copy the archive to the the web server's root directory and then run:

unzip webERP_XXX.zip

this will create the webERP directory under the web server root directory and put all the scripts in that directory.


2. Creating the Database

MySQL version 4.1 or above is required 

INNODB TABLES MUST BE ENABLED IN THE MYSQL SERVER.

Innodb tables allow database transactions and foreign key support, both of which are critical components of ERP software.
Innodb tables require some parameters to be set up in my.cnf - there are some examples in the MySQL manual under table types - Innodb tables.

When using mysql both windows and *nix have the mysql command line client. The command line client is run in a DOS window under Windows. Open a DOS/command window using Start, Run, cmd ENTER for Windows XP and 2000. Normally the mysql client mysql.exe file is under C:\mysql\bin\mysql.exe by default if this path is not in the default path then commands referred to below as mysql will need to be prefixed by C:\mysql\bin

You need to know the user name and password for the MySQL server. If you have not set these up the default is

user root
password ""

BUT.... you should not use this account - you should set up another user for you mysql installation and change the root password to something other than "". There are a number of front ends that allow the mysql user accounts to be maintained and if you are familiar with one of these, it should be used in preference to the mysql command line client discussed below.

From the MySQL manual (edited):

	The MySQL root user is created as a superuser who can do anything. Connections must be made from the local host.
	NOTE: The initial root password is empty, so anyone can connect as root without a password and be granted all privileges.

	Because your installation is initially wide open, one of the first things you should do is specify a password for the MySQL root user. You can do this as follows (note that you specify the password using the PASSWORD() function):

	You can, in MySQL Version 3.22 and above, use the SET PASSWORD statement:

	shell> mysql -u root mysql
	mysql> SET PASSWORD=PASSWORD('new_password');

where 'new_password' is the new password you chose for the root user.

Also from the MySQL manual (edited):

	Also, if you have changed the root user password, you must specify it for the mysql commands below.

	You can add new users by issuing GRANT statements:

	shell> mysql --user=root  -p 'new_password' mysql

	mysql> GRANT ALL PRIVILEGES ON *.* TO weberp_db_user@localhost
        	   IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

Where 'some_pass' is a password of your choice for the new user 'weberp_db_user'. Note that this user weberp_db_user can only connect from the local machine so if the web server is on a different machine to the MySQL server then you need to give privileges to connect from other computers. See the MySQL manual.

If you have an account set up already in MySQL and innodb tables enabled, then all you need to do is to run one of the sql scripts - under the sql directory as unpacked from the archive.

Note: The scripts provided are created using mysqldump and contain comments. Unfortunately, phpMyAdmin doesn't like these comments so it is recommended to follow the instructions below.

Two scripts are provided:

1. weberp-demo.sql  This has a minimal amount of demonstration data in a bogus company set up so that transactions can be tried to see how the system works.
2. weberp-new.sql This script has only the basic data necessary to start a new company system off. If you wish to set up your company on webERP then this is the script to use. Using weberp-new.sql you will need to create a database first (using phpMyAdmin for example) or add the following sql commands to this script CREATE database yourdbname; USE yourdbname;

This creates a weberp database and populates it with only the very basic data to start off.
The files weberp-demo.sql and weberp-new.sql should be in webERP/sql/mysql directory.

shell > mysql --user=weberp_db_user --password='some_pass' < /path_to_the_sql_script/weberp-demo.sql

or

shell > mysql --user=weberp_db_user --password='some_pass' < /path_to_the_sql_script/weberp-new.sql

as required.

3. Editing config.php

config.php contains a series of user defined variables that determine how the system behaves. Critically it contains the user and password of the database connection and the type of database server being used. There is no going forward without the system being provided with this data. It is important to ensure there are no trailing characters at the end of this file - this is a common installation pitfall since some editors add a character at the end of the file.

The file appears as follows for reference purposes. The actual file config.php under the webERP directory with all the other scripts must be edited and saved. As you can see the file is well commented, the critical items are the computer $host, the $dbType, the $dbuser and the $dbpassword - other variables can in most cases be left at their defaults. Note that the sha1 encryption requires the PHP version 4.3 or greater - if you are using a prior version of php - not recommended - you could try md5 encryption. Lines commencing with // are comments and not interpreted by PHP. (Note: In prior versions a variable $DatabaseName used to be required in config.php this is no longer required as the webERP database names available are derived from the directory names under webERP/companies/ - when you create a new database using weberp-new.sql you must also copy the directory structure for the company weberp to another directory under webERP/companies with the same name as the database created. If you are using the demo data and the webERP/sql/mysql/weberp-demo.sql script then the database is created as weberp and the company directory weberp already exists under webERP/companies)


// User configurable variables
//---------------------------------------------------

//DefaultLanguage
$DefaultLanguage ='en_GB';

// Whether to display the demo login and password or not 
$allow_demo_mode = True;

// Application version
$Version = 'XXX';

// The timezone of the business - this allows the possibility of having
// the web-server on a overseas machine but record local time
// this is not necessary if you have your own server locally
// putenv('TZ=Europe/London');
// putenv('Australia/Melbourne');
// putenv('Australia/Sydney');
// putenv('TZ=Pacific/Auckland');

// Connection information for the database
// $host is the computer ip address or name where the database is located
// assuming that the web server is also the sql server
$host = 'localhost';

//The type of db server being used - now only mysql is supported
$dbType = 'mysql';
//$dbType = 'postgres'; /*now depreciated */
//$dbType = 'mysql';

// sql user & password
$dbuser = 'weberp_db_user';
$dbpassword = 'weberp_db_pwd';

//The maximum time that a login session can be idle before automatic logout
//time is in seconds  3600 seconds in an hour
$SessionLifeTime = 3600;

//The maximum time that a script can execute for before the web-server should terminate it
$MaximumExecutionTime =120;

//The path to which session files should be stored in the server
//this can be left commented out if only one company is running on the server
//However if multiple webERP installations are on the same server then a separate session directory is required for each install
//$SessionSavePath = '/tmp';


// which encryption function should be used
//$CryptFunction = "md5"; // MD5 Hash
$CryptFunction = "sha1"; // SHA1 Hash
//$CryptFunction = ""; // Plain Text




4. Logging In For the First Time

Open a browser and enter the URL for the web server directory where webERP is installed if the broswer is on the same machine as the server perhaps

http://localhost/webERP/index.php

enter the user name of 'demo'
password 'weberp'

(the quotation marks are not required).

You can set up additional user accounts from the System Setup tab and change the password.
Be careful not to delete the demo user until a new user has been set up.
If there are no users defined the next time you try to login you won't be able to!
The only way then to create a user to login with is to manually edit the SQL table www_users to insert a user.

If for some reason the demo user is deleted before creating a new system administrator account, the following SQL can be used to create a new user with system administrator privileges - assuming a stock location 'DEN' exists - this should be changes to a valid stock location otherwise:

INSERT INTO `www_users` VALUES ('demo','f0f77a7f88e7c1e93ab4e316b4574c7843b00ea4','Demonstration user','','','','DEN',8,'2005-02-12 21:00:42','','A4','1,1,1,1,1,1,1,1,',0,50,'professional','en_GB');

NB See the importance of setting a password to use the SQL server otherwise anyone could modify www_users and gain access to private company information.

A pdf reader - Acrobat should be installed on the client machines that will access the system. It is recommended that the preferences of Acrobat Reader be changed so as to open a seperate window for acrobat documents rather than display them in the browser.

5. Setting Up System Parameters and Company Specific Data

To initiate a new company go into the script Z_MakeNewCompany.php this creates a new company database with a name of your choice and uploads the logo to the required place - the logo must be a .jpg 

It is imperative to go through each of the screens from the setup tab and enter the appropriate information. Particularly the company informaiton and the configuration settings. Each of these settings together with the narrative explaining what each of the settings does should be reviewed in detail before starting off with the system.

Now the accounting starts....

All the standing configuration data is defined from the system setup tab and each link should be reviewed to enter appropriate data for the business.


Please try not to refer questions about PHP or database configuration 
- check your PHP web server works by installing phpMyAdmin before referring any installation issues
- check http://wikidocs.weberp.org for Installation FAQ

_____________________________________________________________________

LEGAL

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

A copy of the GNU General Public License is included in the doc directory along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Copyright Logic Works Ltd 2007 - Contact: info@weberp.org