I've developed my own solution now which provides functions for generating, verifying and installing update packages.
Basically, it uses PHP's OpenSSL functions for public-key encryption (RSA) of the key for symmetric encryption, mcrypt for symmetric encryption (AES) and ZIP as the container format. These building blocks are used to create compact update packages and ensure data integrity and authenticity.
One could also use openssl_pkcs7_sign()
and openssl_pkcs7_encrypt()
and their counterparts for MIME-compliant encryption, however these functions seem to use 7-bit encoding and therefore make archives rather large.
The web application must have all its files and system-independent data in a single application directory that can be replaced to upgrade the application.
Updating is performed as follows:
Extracting the ZIP archive contents to a temporary location
- Execute a pre-update script
- Move the new application directory to the proper place using a temporary name
- Move the old application directory to another place or rename it
- Rename the new application directory to its expected name
- Run a post-update script
- If anything goes wrong, try to roll back -
Version / source control systems such as git are nice when you are the one in control of all target systems but otherwise I think you should not require the customer to install and operate third-party software for which you would have to provide support as well but rather provide a user interface for software updates that integrates well with the rest of your software.