For hosting PHP powered websites.
- Docker Image tsle/ws-apache-base (see https://github.com/tsitle/dockerimage-ws-apache_base)
- PHP 7.3 (CLI + FPM)
- PHP packages (see below)
- MariaDB Client 10.3 (^= MySQL 5.7/8.0)
- php-pear
- xml-core
- bcmath
- cli
- common
- curl
- fpm
- gd
- gmp
- imagick
- imap
- json
- ldap
- mbstring
- mcrypt
- mysql
- opcache
- readline
- redis
- sqlite3
- xdebug
- xml
- zip
The webserver is listening only on TCP port 80 by default.
See the related GitHub repository https://github.com/tsitle/dockercontainer-ws-apache_php73_mariadb103
From tsle/ws-apache-base:
- CF_PROJ_PRIMARY_FQDN [string]: FQDN for website (e.g. "mywebsite.localhost") (default: empty)
- CF_SET_OWNER_AND_PERMS_WEBROOT [bool]: Recursively chown and chmod CF_WEBROOT? (default: false)
- CF_WWWDATA_USER_ID [int]: User-ID for www-data (default: 33)
- CF_WWWDATA_GROUP_ID [int]: Group-ID for www-data (default: 33)
- CF_ENABLE_CRON [bool]: Enable cron service? (default: false)
- CF_LANG [string]: Language to use (en_EN.UTF-8 or de_DE.UTF-8) (default: empty)
- CF_TIMEZONE [string]: Timezone (e.g. 'Europe/Berlin') (default: empty)
- CF_ENABLE_HTTP [bool]: Enable HTTP for Apache? (default: true)
- CF_CREATE_DEFAULT_HTTP_SITE [bool]: Create default HTTP Virtual Host for Apache? (default: true)
- CF_ENABLE_HTTPS [bool]: Enable HTTPS/SSL for Apache? (default: false)
- CF_CREATE_DEFAULT_HTTPS_SITE [bool]: Create default HTTPS/SSL Virtual Host for Apache? (default: true)
- CF_SSLCERT_GROUP_ID [int]: Group-ID for ssl-cert (default: 102)
- CF_DEBUG_SSLGEN_SCRIPT [bool]: Enable debug out for sslgen.sh?
- CF_CSR_SUBJECT_COUNTRY [string]: For auto-generated SSL Certificates (default: DE)
- CF_CSR_SUBJECT_STATE [string]: For auto-generated SSL Certificates (default: SAX)
- CF_CSR_SUBJECT_LOCATION [string]: For auto-generated SSL Certificates (default: LE)
- CF_CSR_SUBJECT_ORGANIZ [string]: For auto-generated SSL Certificates (default: The IT Company)
- CF_CSR_SUBJECT_ORGUNIT [string]: For auto-generated SSL Certificates (default: IT)
- CF_APACHE_TIMEOUT [int]: Number of seconds before receives and sends time out (default: 300)
From this image:
- CF_WWWFPM_USER_ID [int]: User-ID for wwwphpfpm (default: 1000)
- CF_WWWFPM_GROUP_ID [int]: Group-ID for wwwphpfpm (default: 1000)
- CF_PHPFPM_RUN_AS_WWWDATA [bool]: Run PHP-FPM process as user/group www-data ? (default: false)
- CF_PHPFPM_ENABLE_OPEN_BASEDIR [bool]: (default: false)
- CF_PHPFPM_UPLOAD_TMP_DIR [string]: (default: "/var/www/upload_tmp_dir")
- CF_PHPFPM_PM_MAX_CHILDREN [int]: (default: 5)
- CF_PHPFPM_PM_START_SERVERS [int]: (default: 2)
- CF_PHPFPM_PM_MIN_SPARE_SERVERS [int]: (default: 1)
- CF_PHPFPM_PM_MAX_SPARE_SERVERS [int]: (default: 3)
- CF_PHPFPM_UPLOAD_MAX_FILESIZE [sizestring]: (default: "100M")
- CF_PHPFPM_POST_MAX_SIZE [sizestring]: (default: "100M")
- CF_PHPFPM_MEMORY_LIMIT [sizestring]: (default: "512M")
- CF_PHPFPM_MAX_EXECUTION_TIME [int]: (default: 600)
- CF_PHPFPM_MAX_INPUT_TIME [int]: (default: 600)
- CF_PHPFPM_HTML_ERRORS [bool]: (default: false)
- CF_ENABLE_XDEBUG [bool]: Enable XDebug PHP module? (default: false)
- CF_XDEBUG_REMOTE_HOST [string]: Remote Host for XDebug (default 'dockerhost')
You'll need to create the crontab file ./mpcron/wwwphpfpm
and then add some task to the file:
# the following command will be executed as 'wwwphpfpm'
* * * * * cd /var/www/html/; tar cf backup.tar site-html/> /dev/null 2>&1
Instead of the username wwwphpfpm
you could also use root
.
Now you could enable cron in your docker-compose.yaml file like this:
version: '3.5'
services:
apache:
image: "ws-apache-php73-mariadb103-<ARCH>:<VERSION>"
ports:
- "80:80"
volumes:
- "$PWD/mpweb:/var/www/html"
- "$PWD/mpcron/wwwphpfpm:/var/spool/cron/crontabs/wwwphpfpm"
environment:
- CF_PROJ_PRIMARY_FQDN=example-host.localhost
- CF_WWWFPM_USER_ID=<YOUR_UID>
- CF_WWWFPM_GROUP_ID=<YOUR_GID>
- CF_SET_OWNER_AND_PERMS_WEBROOT=false
- CF_ENABLE_CRON=true
- CF_LANG=de_DE.UTF-8
- CF_TIMEZONE=Europe/Berlin
restart: unless-stopped
stdin_open: false
tty: false
# enable:
$ docker exec -it DOCKERCONTAINER phpenmod xdebug
# disable:
$ docker exec -it DOCKERCONTAINER phpdismod xdebug
$ docker exec -it DOCKERCONTAINER service php7.3-fpm restart