Before installing FARMDATA, make sure that:
php -m | grep pdo_mysql
If the command produces one line of output (containing: pdo_mysql), then the module is installed.
- you have the PEAR PHP extension installed
- you have the Mail and Mail_Mime PEAR packages installed (only for emailing invoices)
- you know your domain name (i.e. web server hostname)
- you know whether or not your web server provides Secure Sockets Layer (SSL) via an SSL certificate. Running FARMDATA over SSL is highly recommended.
- you know the full path to the document root directory for your web server (that is, the directory that your web server serves files from). If you have a dedicated server, the document root directory will be something like "/var/www/html". If you have a shared hosting account, the document root directory will likely be a subdirectory of your home directory.
- you know the subdirectory of the document root directory in which you would like to install FARMDATA. The installation procedure will create this subdirectory if it doesn't exist. Installing directly in the document root directory will work, but is not recommended unless your web server will be used for FARMDATA only. If you install FARMDATA in the document root directory, the URL for FARMDATA will just be the hostname of your server. If you install in a subdirectory of the document root directory, the URL
will be: https://your.server.name/subdirectory.name
(http://your.server.name/subdirectory.name if you are not using SSL)
-
you know whether MySQL is running on your web server, or on a different server. If MySQL is running on a different server, you will have to create and populate the databases on that server as described in Section "When MySQL Is Running on a Different Server" below. Do this before installing FARMDATA.
-
you decide whether to have the installation procedure create the necessary MySQL databases for you, or if you would like to create those databases yourself.
-
If you decide to have the installation procedure create the databases, you will need to enter the username and password for a MySQL administrator account on your system - that is, a user that can create databases and additional database users. You will be prompted for this username and password during the installation procedure.
-
If you create the databases yourself (recommended in a shared hosting environment), create two MySQL databases. One will be used for storing user account information, and the second for storing the actual planting, harvesting, ... data. You will also need to create a user for each database with full privileges on that database. You MUST create a separate user for each database. You will be prompted for the name of each database, user and password during the installation procedure. After installation, adjust the privileges for each user as follows:
- the user for the user account information database needs select, insert and update privileges on that database (remove all others)
- the user for the farm information database needs lock tables, select, delete, insert, show view and update privileges on that database (remove all others)
-
you have chosen a username and password for your FARMDATA account.
Installing FARMDATA
- cd into the FARMDATA1.X directory (created when you unpacked the FARMDATA source). The X represents the FARMDATA version number - currently 1 - 5.
- execute the command:
chmod 755 install.sh
to ensure that the install procedure can be executed
- execute the command:
./install.sh
- the install procedure will prompt you for the information listed above
- after collecting all information, the install procedure will create and populate databases as needed, configure the source files and move them to the correct directory. Additionally, the install procedure will create a file called
config that contains the details of your FARMDATA configuration. Copy this file to a safe location, as you will need it in order to upgrade to new FARMDATA versions in the future.
- report any installation issues by creating a ticket at:
https://sourceforge.net/p/farmdata/tickets/
Make sure to copy and paste any error messages into your ticket. Note that you need to be a sourceforge member to create a ticket.
To begin using FARMDATA, go to the URL specified above and log in with the username and password that you specified during the installation. For a quick start on configuring FARMDATA (highly recommended), log in to:
https://your.server.name/subdirectory.name/setup
When MySQL Is Running on a Different Server
If your MySQL server and web server are not the same, you will need to log in to your MySQL server to create and populate the databases for FARMDATA. Do this before running the install procedure as described in the previous section.
- as described in Section "Planning Your FARMDATA Installation" above, create the user account and farm information databases and a database user for each. You will likely do this via cpanel or some other control panel provided by your web hosting company.
- use phpMyAdmin to log in to the user account database as either the user for the user account database that you created above or an administrative user.
- click the SQL tab, and copy and paste the contents of the file tables/userTables.txt (from the FARMDATA1.X directory) into the "Run SQL Query" box. Click "Go" and verify that the query executed successfully.
- clear the contents of the "Run SQL Query Box"
-
in the "Run SQL Query" box, enter:
insert into farms values ('INFODB', 'INFODBPASS', 'INFODBUSER');
where:
- INFODB is the name of the farm information database
- INFODBPASS is the password of the farm information database user
- INFODBUSER is the username of the farm information database user
The single quotes (') around each of these values are required. Click "Go" and verify that the query executed successfully.
-
go to this website: https://www.functions-online.com/crypt.html to get the encrypted value of your FARMDATA password
- enter whatever you would like your FARMDATA password to be for
$str and 123salt for $salt. Click "Run", and copy the value of result
- back in phpMyAdmin, clear the contents of the "Run SQL Query Box"
-
in the "Run SQL Query" box, enter:
insert into users values ('USERNAME', 'PASSWORD', 'INFODB', 1, 1);
where:
- USERNAME is what you would like for your FARMDATA username. Many people will use an email address for this.
- PASSWORD is the encrypted value that you copied above.
- INFODB is the name of the farm information database. Again, the single quotes around these values are required.
- the 1's specify that you are a FARMDATA administrative user, and that your account is active
-
Click "Go" and verify that the query executed successfully.
- log out of phpMyAdmin
- use phpMyAdmin to log in to the farm information database as either the user for the farm information database that you created above or an administrative user.
- click the SQL tab, and copy and paste the contents of the file tables/baseTables.txt (from the FARMDATA1.X directory) into the "Run SQL Query" box. Click "Go" and verify that the query executed successfully.
- clear the contents of the "Run SQL Query Box"
- copy and paste the contents of the file tables/dfTables.txt (from the FARMDATA1.X directory) into the "Run SQL Query" box. Click "Go" and verify that the query executed successfully.
- proceed with normal FARMDATA installation as described in the previous section.
- when you are finished, you should be able to log in to FARMDATA using the username you specified above and the unencrypted password that you specified. That is, use the value that you typed for
$str and not the encrypted value that the website returned.
Upgrading FARMDATA
To upgrade to a new version of FARMDATA while keeping your existing databases (and their contents):
- download the new version of FARMDATA and unpack it. We will refer to this version as FARMDATA1.X.
- copy the
config file that was created when you installed FARMDATA from the original installation directory into the FARMDATA1.X directory that was created in the previous step.
- cd into the FARMDATA1.X directory
- execute the command:
./install.sh
- the install procedure will ask you to accept the license agreement, and whether your web server supports SSL. If you have obtained an SSL certificate since installing FARMDATA, you can upgrade FARMDATA to run over SSL by answering "y" here.
- the install procedure will detect the
config file and ask you whether you wish to upgrade your existing FARMDATA or to do a new installation. If you decide to do a new installation, delete both databases created during your initial FARMDATA installation before proceeding. If you decide to upgrade your existing FARMDATA, the install procedure will configure the new source files and copy them to the installation directory, but will leave your existing databases unchanged.
NOTE: to upgrade by multiple versions, follow the upgrade instructions for each intermediate version. For example, to upgrade from FARMDATA 1.2 to FARMDATA 1.5, first make the table modifications specified below for upgrading from FARMDATA 1.2 to FARMDATA 1.3, and then the modifications for upgrading from FARMDATA 1.3 to 1.4 (none in that case), and then finally the modifications for upgrading from FARMDATA 1.4 to 1.5. You only need to upgrade the code for the version you are upgrading to - that is, you do not need to download the code for and upgrade to FARMDATA 1.3 and 1.4 to upgrade from FARMDATA 1.2 to 1.5.
Upgrading from FARMDATA1.0 to FARMDATA1.1
If you are upgrading from FARMDATA1.0 to FARMDATA1.1, you must adjust several of the
tables in your farm information database (in addition to the upgrading the code as in the previous section). Connect to your farm information database from phpMyAdmin or a terminal and execute the following commands. In phpMyAdmin, paste the commands into the "Run SQL Query" box and click "Go":
alter table coverCrop drop column id;
alter table coverCrop add column active tinyint(1) default 1 after legume;
alter table tSprayMaterials modify column REI_HRS varchar(20);
alter table gh_seeding add column gen int default 1 after cellsFlat;
alter table dir_planted add column gen int default 1 after hours;
alter table transferred_to add column gen int default 1 after flats;
alter table harvested add column gen int default 1 after unit;
alter table config add column gens tinyint(1) default 1 after bedft;
Upgrading from FARMDATA1.1 to FARMDATA1.2
To upgrade from FARMDATA1.1 to FARMDATA1.2, you must adjust one additional table in your farm information database. The necessary command is:
alter table distribution add column pricePerUnit double default 0 after unit;
Upgrading from FARMDATA1.2 to FARMDATA1.3
To upgrade from FARMDATA1.2 to FARMDATA1.3, you must adjust several tables in your farm information database. The necessary commands are:
alter table comments add column id int auto_increment primary key;
alter table product add column active tinyint(1) default 1;
alter table tSprayField add column crops text;
update tSprayField set crops = (select crops from tSprayMaster where tSprayMaster.id = tSprayField.id);
alter table tSprayMaster drop column crops;
Upgrading from FARMDATA1.3 to FARMDATA1.4
No table modifications are necessary when upgrading from FARMDATA1.3 to FARMDATA1.4. Simply follow the upgrading instructions above.
Upgrading from FARMDATA1.4 to FARMDATA1.5
To upgrade from FARMDATA1.4 to FARMDATA1.5, you must adjust several tables in
your farm information database. The necessary commands are:
alter table utilized_on modify fieldSpread float;
alter table dir_planted add column annual tinyint(1) default 1;
alter table dir_planted add column lastHarvest date;
update dir_planted set lastHarvest = concat(year(plantdate), '-12-31');
alter table dir_planted modify lastHarvest date not null;
alter table dir_planted modify plantdate date not null;
alter table transferred_to add column annual tinyint(1) default 1;
alter table transferred_to add column lastHarvest date;
update transferred_to set lastHarvest = concat(year(transdate), '-12-31');
alter table transferred_to modify lastHarvest date not null;
alter table transferred_to modify transdate date not null;
Adding Farms to an Existing FARMDATA Installation
The procedure for adding a new farm will prompt you for the MySQL admin username and password, the user's database, and the full path to the installation directory. The user's database is the first value in the config file that was created when you installed FARMDATA, and the installation directory is the second to last value in this file. (The values in this file are separated by :'s.) Make sure that you have this information before adding a new farm.
To add a new farm:
- in the FARMDATA1.X directory, execute the command:
./addfarm.sh
- enter the information listed above when prompted
- enter the name of the database for the new farm and the username and password for the initial user (admin) account when prompted
- enter the full path to the installation directory when prompted
The new farm will then be added to the existing FARMDATA installation. The URL is the same for all farms that use the same FARMDATA installation.