The PHP common API now supports automatic updates which running an On-Premise installation. Automatic updates is realised by calling the ‘update.php’ script found in the common API directory. To enable automatic updates, you will need to set up a scheduled job:
It is important that the data file has the correct permissions to be accessed by the webserver, this can be done by setting the owning user/group to that of the webserver or updating the ‘rwx’ permissions on the datafile. E.g. ‘chmod 755 /var/www/html/51Degrees-EnterpriseV3.2.dat’
- - Create a bash script called ‘51DUpdate.sh’ with the contents: content=$(curl -L localhost/update.php)
- - Save this in /etc/cron.daily/
- - Run crontab -e
- - Append the following line to enable automatic updates: 0 0 * * * /etc/cron.daily/51DUpdate.sh
The cron job will now execute every day at midnight, the script will make a request to the ‘update.php’ script. The script will download and update the existing data file then reload the provider.
To prevent users from forcing an update it is recommended that access to the ‘update.php’ file is denied from external interfaces.
On windows, automatic updates can be enabled using a PowerShell script that is run via scheduled task. To set up automatic updates on Windows, make a PowerShell script called 51DUpdate.ps1 with the contents:
$content = Invoke-WebRequest http://localhost/
A Scheduled Task can be used to run this script with a frequency of once a day. As the most frequently updated data file is released daily, there is little to no benefit to running this more than once per day.