The PHP-CMS eShop project was at the origin of this application
Using the basic container orchestrator or engine to deploy and test, is straitforward.
Currently the deployment script
. deploy.sh
Based on Balena engine. See more about NodeJs dependencies
To deploy a server or onto a container manager like docker, you need at least a developer environment with the following software:
- PHP 7.4 or later in PATH
- NodeJS 19 or later in PATH and NPM or Yarn (recommended in Windows)
- Package managers NPM or Yarn, also HomeBrew, MacPorts or Chocolatey, etc.
- a Docker setup (Mac or PC) or BalenaEngine (Linux)
- (recommended for Windows) git unix-style shell, like Git Bash
- OpenSSH Agent with key-pair (.ssh/*.pub) must be added to the webserver host
Once you have got the server up and running (usually in a docker container), the website may not be reacheable until the database is configured. You need to have network access to the host running the webservice as a container, just connect to it, with BalenaOS it's very easy:
./balena-connect-it.sh 22222 <user@host-ip> acake2php
Otherwise use:
ssh -ttp <port> <user@host-ip> docker exec -it <container-name> "/bin/sh"
Once you're logged in, run as a normal user in /var/www/localhost/htdocs # :
./configure.sh -d -i -u
It will configure PHP plugins and migrate the table in databases.
You can also test the configuration, lauch Cake Tests from /var/www/localhost/htdocs # :
./test-cake.sh
You do not need to change anything in your existing PHP project's repository. However, if these files exist they will affect the behavior of the build process:
-
Packagist composer.json
Update all required plugins
composer update
-
package.json
List of dependencies to be installed with
npmjshere.yarnInstall the balenaCloud helper package balena-cloud-apps.
sudo npm link balena-cloud-appswhenever the system complains about
balena_deploynot found. -
Templates files
Setup environment variables, build files, ready for deployment with any of the available targets:
Scripts/update-templates.sh
Plugins are registered in both git submodule and composer.json. To make them ready for build, edit composer.json as needed and launch the command composer update.
Plugins home folder:
app/Vendor/<package-name>
app/Plugin/<plugin-name>/
-
.htaccess
To allow Apache server to browse directly to the app/webroot folder on server-side, use mod_rewrite rules, as provided by .htaccess files.
/.htaccess
<IfModule mod_rewrite.c> RewriteEngine on # Uncomment if you have a .well-known directory in the root folder, e.g. for the Let's Encrypt challenge # https://tools.ietf.org/html/rfc5785 #RewriteRule ^(\.well-known/.*)$ $1 [L] RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] </IfModule>/app/.htaccess
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase /app/ RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L] </IfModule>
- CakePHP application also supports Docker
- MariaDB 10.1 and later
Start a local server machine for testing on port 9000. Open a Terminal window:
DB=Mysql ./configure.sh --mig-database -u
./start-cake.sh --docker -c server -p 9000
Ctrl-click the URL that appear on the terminal. It will open them in the browser. To get more help about the command line interface :
./start-cake.sh --help
JUNIT tests are available with the following call to CAKE server: Open a Terminal window:
./test-cake.sh
There are options (--runner, --travis) dedicated to continuous integration build environments. Use --help to see more about options.
See below to allow access on the built-in local server.
When deployment happens on device or is triggered by a git push event, 'source-to-image (s2i)', the httpd-server or pod needs proper environment variables to be set ready. Otherwise the scripts will fail with an error state, unable to connect to the database
The following variables must be set up as server environment, provided by your database administrator:
# Sqlite, Postgres
DB:Mysql
Note: DB selects CakePhp Model/Datasource/Database DBOSource class to configure SQL connections.
MYSQL_DATABASE:default
# a hostname or IP address
MYSQL_HOST:mysql
Note: Prefixed with TEST_ they are used by the index.php?test=1 URLs and ./test-cake.sh (--travis)
The following additional variables must be set up as server secrets environment, provided by your database administrator:
#(optional)
WEBHOOK_URL:<discordapp-url>
# Persistent connection credentials
DATABASE_USER:<provided-user>
MYSQL_ROOT_PASSWORD:<provided-password>
# Just add MYSQL_USER and MYSQL_PASSWORD
MYSQL_USER:<test-user>
MYSQL_PASSWORD:<test-password>
# CakePHP generated
CAKEPHP_SECRET_TOKEN:<secret-token>
CAKEPHP_SECRET_SALT:<secret-salt>
CAKEPHP_SECURITY_CIPHER_SEED:<cipher-seed>
# Generated by ./configure.sh -h
GET_HASH_PASSWORD:<hashed-password>
MYSQL_DATABASE
aria_db
MYSQL_HOST
db
MYSQL_PASSWORD
maria-abc
MYSQL_ROOT_PASSWORD
mariadb
MYSQL_TCP_PORT
3306
MYSQL_USER
maria
SERVER_NAME
<Domain-Name>
Container engines provides a sanbox virtual system with some persistent storage. To check that the last database migration was successful, open a pod shell :
mysql -uroot --password=${MYSQL_ROOT_PASSWORD}
Issue some SQL statements, for instance :
use aria_db; show tables;
To temporarily change the MYSQL_ROOT_PASSWORD in a pod:
mysql_secure_installation
This should list all the migrated tables
cake schema update --connection=default
This should migrate the databases.
cake schema update --connection=test
This should migrate the test databases.
By editing the files Config/app_local.template and Config/Schema/AppSchema.template if you wish to modify the database connection and email transport.
You can then configure and migrate databases (configuration and migration)
./configure.sh -d -i -u
More about configuration:
./configure.sh --help && ./migrate-database.sh --help
More common issues
To sign in with staff rights, at http://localhost/admin/index.php, somebody needs a unique password stored in GET_HASH_PASSWORD. One way to generate this hashed password with "hashed“ encryption and setup:
./configure.sh -p <password> -s <hash>
To regenerate or read the current password hash again, simply browse to http://localhost/php-cms/e13/etc/getHashPassword.php
HASH_PASSWORD=<unencrypted Password>
or:
GET_HASH_PASSWORD=<encrypted Password>
One of them must be stored in the local server environment as a system readable variable.
If selecting an ARM device target from an ordinary X86 machine, first enable the RUN [ cross-build-start ] and RUN [ cross-build-end ] balenaOS cross-platform build modes, run ./deploy.sh:
1:local-balena
Choose the target architecture, and then choose the option:
6:build dependencies
Only balenaOS baselib images can use cross-build based on balenaEngine. You should otherwise run docker buildx build --platform=linux/arm64 from an ARM computer.
BalenaOS and BalenaCloud as an open source platform allow us to maintain a small devices fleet (aka swarm, cluster).
Use Balena one button deployment, update the source code as your needs, and deploy to BalenaCloud, this will disable cross-platform build:
2:balena
5:push
You are able to deploy to a balena fleet, using their original deployment process.
You should configure a DOCKER_USER and DOCKER_PASS as environment variables. You may use an access_token for DOCKER_PASS for better security.
Copyright 2016-2025 www.b23prodtm.info
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.