Compare commits

..

25 Commits

Author SHA1 Message Date
468bc7b088 Move user crontab to persistent home directory
All checks were successful
Cloud Apache Container / Build-and-Push (74) (push) Successful in 1m52s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 1m48s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 1m45s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 1m54s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 1m50s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 1m48s
- Created user-specific crontab file at /home/$user/crontab
- Crontab now persists through container restarts/refreshes
- Users can manage their own cron jobs by editing their crontab file
- Automatically loads user crontab on container start
- Updated DEV environment to use user crontab for MySQL backups

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 07:36:35 -07:00
8b9708e351 Add essential development tools to container
All checks were successful
Cloud Apache Container / Build-and-Push (74) (push) Successful in 3m31s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 2m55s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 1m58s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 1m52s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 1m48s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 3m24s
Added git, nano, rsync, unzip, zip, mariadb client, bind-utils, jq, patch, nc, tree, and dos2unix to provide developers with commonly needed tools for PHP development and debugging.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-13 07:19:25 -07:00
92ed9885ec Remove php-ioncube-loader from PHP 8.1 to fix Composer installation
All checks were successful
Cloud Apache Container / Build-and-Push (74) (push) Successful in 1m48s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 1m44s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 1m42s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 1m43s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 1m47s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 2m15s
The php-ioncube-loader package is incompatible with PHP 8.1 and was causing
a segmentation fault (exit code 139) when the Composer installer tried to
run PHP. This aligns PHP 8.1 with other PHP versions that already had
ioncube-loader removed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-12 16:41:33 -07:00
844b21bd7c Add Composer to container for PHP dependency management
Some checks failed
Cloud Apache Container / Build-and-Push (74) (push) Successful in 3m1s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 2m0s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 1m58s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 2m3s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 2m2s
Cloud Apache Container / Build-and-Push (81) (push) Failing after 1m28s
- Install Composer globally at /usr/local/bin/composer
- Available for all PHP versions and users
- Also includes previously added microdnf and less utilities

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-12 15:50:18 -07:00
3d903b437f Fix PHP error log path to use correct user directory
All checks were successful
Cloud Apache Container / Build-and-Push (74) (push) Successful in 1m45s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 1m39s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 1m38s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 1m39s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 1m42s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 1m50s
PHP error logs were incorrectly being written to /etc/httpd/logs/error_log
instead of the expected /home/$user/logs/php-fpm/ directory. Updated the
php_admin_value[error_log] setting to point to the proper location.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-31 10:21:15 -07:00
152dd413ef adding claude infor
All checks were successful
Cloud Apache Container / Build-and-Push (74) (push) Successful in 3m12s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 1m37s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 1m54s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 2m23s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 2m8s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 3m21s
2025-07-28 07:29:03 -07:00
617fdbcd21 Add PostgreSQL support for all PHP versions
- Added postgresql-devel package to Dockerfile for client libraries
- Added php-pgsql extension to all PHP versions (7.4, 8.0, 8.1, 8.2, 8.3, 8.4)
- Enables PHP applications to connect to PostgreSQL databases

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-28 07:27:39 -07:00
154f42ae09 Optimize memory usage for Apache and PHP-FPM, remove ioncube-loader
All checks were successful
Cloud Apache Container / Build-and-Push (74) (push) Successful in 3m7s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 1m42s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 1m37s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 1m39s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 3m3s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 1m40s
- Apache mpm_event: Reduced StartServers from 10 to 2, adjusted spare threads
  and worker limits for container environments
- PHP-FPM: Switched from static to dynamic process management with lower
  process counts (5 max children instead of 10)
- Removed php-ioncube-loader from PHP 8.0 installation
- Expected memory reduction: 60-70% in idle state while maintaining responsiveness

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-20 16:52:04 -07:00
b5857d73c2 Fix issue where PHP Sessions were not working as expected
All checks were successful
Cloud Apache Container / Build-and-Push (74) (push) Successful in 2m37s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 44s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 1m41s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 1m39s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 1m37s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 1m35s
2025-07-20 12:06:15 -07:00
b1de7021a3 fix build issues
All checks were successful
Cloud Apache Container / Build-and-Push (74) (push) Successful in 2m44s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 1m38s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 8m24s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 5m1s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 7m30s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 8m55s
2025-07-16 08:01:07 -07:00
9f8beb45b8 Switching builds to include PHP version to limit memory requirements on deploy.
Some checks failed
Cloud Apache Container / Build-and-Push (74) (push) Failing after 56s
Cloud Apache Container / Build-and-Push (80) (push) Failing after 36s
Cloud Apache Container / Build-and-Push (81) (push) Failing after 56s
Cloud Apache Container / Build-and-Push (82) (push) Failing after 55s
Cloud Apache Container / Build-and-Push (83) (push) Failing after 40s
Cloud Apache Container / Build-and-Push (84) (push) Failing after 57s
improve build size and speed for images.
2025-07-16 07:55:03 -07:00
88f462eb04 Updated the README.md
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 1m1s
Added a healthcheck to the container
adjusted Apache limits for memory consumption
switch to microdnf for improved memory usage
2025-07-16 05:56:33 -07:00
e7b0bce666 Update MariaDB Version
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 41s
2025-06-14 16:02:00 -07:00
5a097034c4 Update MariaDB Version
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 44s
2025-03-16 11:12:46 -07:00
a41157fad0 fix url
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 39s
2025-03-16 10:58:25 -07:00
4fd7ee465a Adding support for PHP 8.4 and upgrading MariaDB to 11.4.5
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 47s
2025-03-16 10:43:16 -07:00
8a7490ef98 forgot to add iproute
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 1m32s
2024-12-17 21:52:38 -08:00
jknapp
9df776ef08 Merge pull request 'fix path to remote_ip.conf' (#18) from update-to-fix-ip-and-options-issue into trunk
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 39s
Reviewed-on: #18
2024-12-18 05:47:59 +00:00
7bab6d39fc fix path to remote_ip.conf 2024-12-17 21:47:32 -08:00
jknapp
9630408ca0 Merge pull request 'Added fix for issues found while setting up anhonesthost' (#17) from update-to-fix-ip-and-options-issue into trunk
Some checks failed
Cloud Apache Container / Build-and-Push (push) Failing after 8s
Reviewed-on: #17
2024-12-18 05:44:51 +00:00
49c5438866 Added fix for issues found while setting up anhonesthost 2024-12-17 21:44:09 -08:00
jknapp
885deb5979 Merge pull request 'fix spacing on versions' (#16) from fix-readme into trunk
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 35s
Reviewed-on: #16
2024-10-16 01:50:31 +00:00
23253e9f37 fix spacing on versions 2024-10-15 18:50:11 -07:00
jknapp
fde567d5f9 Merge pull request 'Fix/Update README.md' (#15) from fix-readme into trunk
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 35s
Reviewed-on: #15
2024-10-16 01:45:51 +00:00
b2675abc30 Fix/Update README.md 2024-10-15 18:44:09 -07:00
17 changed files with 341 additions and 87 deletions

39
.dockerignore Normal file
View File

@@ -0,0 +1,39 @@
# Ignore version control
.git
.gitignore
# Ignore CI/CD and workflow files
.gitea/
.github/
.gitlab/
# Ignore local development files
*.swp
*.swo
*.bak
*.tmp
*.log
# Ignore OS and editor files
.DS_Store
Thumbs.db
.vscode/
.idea/
# Ignore test and documentation files
tests/
docs/
README*
# Ignore node and Python artifacts (if present)
node_modules/
__pycache__/
# Ignore build output
dist/
build/
# Ignore secrets and configs
*.env
.env.*
secrets/

View File

@@ -8,6 +8,9 @@ on:
jobs:
Build-and-Push:
runs-on: ubuntu-latest
strategy:
matrix:
phpver: [74, 80, 81, 82, 83, 84]
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -16,19 +19,22 @@ jobs:
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v3
- name: Login to Gitea
uses: docker/login-action@v3
with:
registry: repo.anhonesthost.net
username: ${{ secrets.CI_USER }}
password: ${{ secrets.CI_TOKEN }}
- name: Build Image
- name: Build and Push Image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: true
build-args: |
PHPVER=${{ matrix.phpver }}
tags: |
repo.anhonesthost.net/cloud-hosting-platform/cac:latest
repo.anhonesthost.net/cloud-hosting-platform/cac:php${{ matrix.phpver }}
${{ matrix.phpver == '84' && 'repo.anhonesthost.net/cloud-hosting-platform/cac:latest' || '' }}

86
CLAUDE.md Normal file
View File

@@ -0,0 +1,86 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
Cloud Apache Container (CAC) is a Docker-based PHP web hosting environment that supports multiple PHP versions (7.4 through 8.4) with Apache, designed for both local development and production deployment.
## Common Development Commands
### Local Development Setup
```bash
# Quick start with automated setup (creates helper scripts)
./local-dev.sh -n local-dev
# With specific PHP version
./local-dev.sh -n myproject -a 84 # PHP 8.4
# Helper scripts created by local-dev.sh:
./instance_start # Start container
./instance_stop # Stop container
./instance_logs # Tail Apache logs
./instance_db_info # Show MySQL credentials
```
### Building and Testing
```bash
# Build container locally
docker build -t cac:latest .
# Build with specific PHP version
docker build --build-arg PHP_VER=83 -t cac:php83 .
# Run container manually
docker run -d -p 80:80 -p 443:443 \
-e PHPVER=83 -e environment=DEV \
-e uid=$(id -u) -e user=$(whoami) -e domain=localhost \
-v"$(pwd)/user":/home/$(whoami) \
--name test-container cac:latest
```
### Server Deployment
- Production git directory: `/root/whp`
- After `git pull`, sync web files: `rsync -av web-files/ /docker/whp/web/`
## Architecture and Key Components
### Directory Structure
- `/scripts/` - Container setup scripts (entrypoint, PHP installers, vhost creation)
- `/config/` - Apache and PHP configuration files
- `/web-files/` - Default web content (ping endpoint)
- `/.gitea/workflows/` - CI/CD pipeline for multi-PHP version builds
### Container Behavior
1. **Entrypoint Flow** (`scripts/entrypoint.sh`):
- Creates user with specified UID
- Sets up directory structure
- Configures Apache vhost based on environment variables
- In DEV mode: starts MariaDB and Memcached
- Starts Apache and PHP-FPM
2. **Environment Modes**:
- **DEV** (`environment=DEV`): Local database, memcached, automatic backups
- **PROD** (default): Expects external database/cache services
3. **PHP Version Management**:
- Controlled via `PHPVER` environment variable (74, 80, 81, 82, 83, 84)
- Each version has dedicated install script in `/scripts/`
- PHP-FPM configuration dynamically created based on version
### Key Environment Variables
- `uid` (required): User ID for file permissions
- `user` (required): Username for container user
- `domain` (required): Primary domain for Apache vhost
- `serveralias`: Additional domains (comma-separated)
- `PHPVER`: PHP version to use (default: 83)
- `environment`: DEV or PROD mode
## Important Technical Details
1. **Health Check**: Available at `/ping` endpoint
2. **Logs Location**: `/home/$user/logs/apache/` and `/home/$user/logs/php-fpm/`
3. **Database Backups** (DEV mode): Every 15 minutes to `/home/$user/_db_backups/`
4. **Log Rotation**: Compress after 3 days, delete after 7 days
5. **SSL**: Self-signed certificate auto-generated, proper SSL configured
6. **WordPress**: WP-CLI pre-installed for WordPress development

View File

@@ -1,23 +1,46 @@
FROM almalinux/9-base
ARG PHPVER=81
RUN dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y
RUN dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
RUN dnf update -y && dnf upgrade -y
RUN dnf install -y httpd mod_ssl wget procps cronie
RUN openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/localhost.key -x509 -days 3650 -subj "/CN=localhost" -out /etc/pki/tls/certs/localhost.crt
RUN mkdir /run/php-fpm/
RUN mkdir /scripts
COPY ./scripts/* /scripts/
ARG PHPVER=83
# Install repos, update, install only needed packages, clean up in one layer
RUN dnf install -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
https://rpms.remirepo.net/enterprise/remi-release-9.rpm && \
dnf update -y && \
dnf install -y httpd mod_ssl wget procps cronie iproute postgresql-devel microdnf less git \
nano rsync unzip zip mariadb bind-utils jq patch nc tree dos2unix && \
dnf clean all && \
rm -rf /var/cache/dnf /usr/share/doc /usr/share/man /usr/share/locale/*
# Copy scripts into the image and set permissions
COPY ./scripts/ /scripts/
RUN chmod +x /scripts/*
#RUN /scripts/install-php$PHPVER.sh
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
RUN chmod +x wp-cli.phar
RUN mv wp-cli.phar /usr/local/bin/wp
# Generate self-signed cert, create needed dirs, install PHP, clean up
RUN openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/localhost.key -x509 -days 3650 -subj "/CN=localhost" -out /etc/pki/tls/certs/localhost.crt && \
mkdir -p /run/php-fpm/ && \
/scripts/install-php$PHPVER.sh && \
rm -rf /tmp/*
# Download and install wp-cli (consider pinning version for reproducibility)
RUN curl -L -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
chmod +x /usr/local/bin/wp
# Download and install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
chmod +x /usr/local/bin/composer
# Copy configs and web files
COPY ./configs/default-index.conf /etc/httpd/conf.d/
COPY ./configs/prod-php.ini /etc/php.ini
COPY ./configs/phpinfo.php /var/www/html/
COPY ./configs/mariadb.repo /etc/yum.repos.d/
COPY ./configs/index.php /var/www/html/
RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab
RUN yum clean all
COPY ./configs/remote_ip.conf /etc/httpd/conf.d/
# Set up cron job in a single layer
RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD curl -f http://localhost/ || exit 1
ENTRYPOINT [ "/scripts/entrypoint.sh" ]

149
README.md
View File

@@ -1,73 +1,134 @@
# Cloud Apache Container #
This is the base container for running PHP based applications. Select the PHP version environment variables. PHP Version Defaults to PHP 8.1
# Cloud Apache Container
*__You mush have docker or compatable containerization software running.__*
This is a base container for running PHP-based applications, supporting multiple PHP versions (7.4, 8.0, 8.1, 8.2, 8.3, 8.4). The default is PHP 8.3. The container is based on AlmaLinux 9 and uses Apache with mod_ssl. It is designed for both development and production use.
__You can pull this image locally by running:__
**You must have Docker or compatible containerization software running.**
```console
docker pull repo.anhonesthost.net/cloud-hosting-platform/cac:latest
---
## What's New?
- **Optimized Image:** The Dockerfile has been refactored for smaller size, faster builds, and improved security. Unnecessary files and caches are removed during build.
- **Pre-built Images for Each PHP Version:** On every push, images for all supported PHP versions are built and pushed to the registry. You can pull the exact version you need (e.g., `cac:php74`, `cac:php84`, or `cac:latest`).
- **.dockerignore Added:** The build context is now minimized, making builds faster and more secure.
---
## Quick Start: Local Development with `local-dev.sh`
The easiest way to start a local development environment is with the provided `local-dev.sh` script. This script automates container setup, volume creation, log directories, and WordPress installation.
### Usage Example
```bash
./local-dev.sh -n local-dev
```
__You can then run a development version of the server by running the following commands:__
*Note this is an example, you can modify the command(s) to fit your needs.*
**Flags:**
- `-n` Name of the container (required)
- `-p` HTTP port (default: 80)
- `-s` HTTPS port (default: 443)
- `-r` Root path for files and database (default: current directory)
- `-a` PHP version (default: 8.3; options: 74, 80, 81, 82, 83, 84)
- `-v` Enable verbose mode
- `-h` Show help
```console
The script will:
- Create a user directory and log folders
- Create a Docker volume for MySQL
- Start the container with the correct environment variables
- Generate helper scripts in your root path:
- `instance_start` Start the container
- `instance_stop` Stop the container
- `instance_logs` Tail Apache logs
- `instance_db_info` Show MySQL credentials
- Install WordPress in your web root
- Print MySQL credentials
---
## Manual Docker Usage
You can also run the container manually:
```bash
mkdir -p local-development/domain.tld
cd local-development/domain.tld
mkdir user
mkdir -p user/logs/{apache,system}
docker run -d -it -p 80:80 -p 443:443 -e PHPVER=81 -e environment=DEV --mount type=bind,source="$(pwd)"/user,target=/home/myuser --mount type=bind,source="$(pwd)"/user/logs/apache,target=/etc/httpd/logs --mount type=bind,source="$(pwd)"/user/logs/system,target=/var/log -v"$name-mysql":/var/lib/mysql -e uid=30001 -e user=myuser -e domain=domain.tld -e serveralias=www.domain.tld --name local-dev repo.anhonesthost.net/cloud-hosting-platform/cac:latest
docker run -d -it -p 80:80 -p 443:443 -e PHPVER=84 -e environment=DEV --mount type=bind,source="$(pwd)"/user,target=/home/myuser -v"$name-mysql":/var/lib/mysql -e uid=30001 -e user=myuser -e domain=localhost --name local-dev repo.anhonesthost.net/cloud-hosting-platform/cac:latest
```
*This will start the processes needed to run sites locally.*
---
The first time you start the container, it will take some time as it is installing all the required software to run the dev instance.
## Accessing the Container
__If you need to get into the container you can run:__
```console
```bash
docker exec -it local-dev /bin/bash
```
__To install WordPress for your site__
---
```console
cat /var/lib/mysql/creds
## WordPress Installation
If using `local-dev.sh`, WordPress is installed automatically. For manual setup:
```bash
cat /home/myuser/mysql_creds
su - myuser
cd ~/public_html
wp core download
```
You should be able to then go into your browser and go to https://localhost (accept the SSL warning if it appears) and follow the prompts to setup the site.
Then visit https://localhost (accept the SSL warning) to complete setup.
The database credentials are shown in the /home/```$user```/mysql_creds file, which we had *cat* in the commands above. They will also be stored in your user directory.
---
### PHPVER ###
*74* - PHP 7.4
*80* - PHP 8.0
*81* - PHP 8.1
*82* - PHP 8.2
*83* - PHP 8.3
## Features
### Environment Variables ###
__Required Tags__
*uid* - User ID for File Permissions
*user* - Username for File Permissions
*domain* - Primary Domain for configuration
- **Multiple PHP Versions:** 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 (set with `PHPVER` or `-a` flag)
- **Pre-built Images:** Pull the image for your desired PHP version directly from the registry. No need to build locally unless customizing.
- **Optimized Build:** Smaller, faster, and more secure images thanks to the improved Dockerfile and `.dockerignore`.
- **Automatic Database Setup:** MariaDB is started in DEV mode, credentials are auto-generated and stored in `/home/$user/mysql_creds`.
- **Database Backups:** Cron job backs up the database every 15 minutes to `/home/$user/_db_backups`.
- **Log Management:** Log rotation compresses logs older than 3 days and deletes those older than 7 days.
- **Memcached:** Started automatically in DEV mode.
- **SSL:** Self-signed certificate enabled by default.
- **Default Web Content:** `/home/$user/public_html` is the web root. `/ping` endpoint and `phpinfo.php` are available for diagnostics.
- **Helper Scripts:** `instance_start`, `instance_stop`, `instance_logs`, `instance_db_info` (created by `local-dev.sh`).
__Optional Tags__
*environment* - Set to DEV to start memcached and mysql locally for development purposes
*serveralias* - Set to allow alternative hostnames for a site.
*PHPVER* - Set to use a different version of PHP [refer to versions here.](#phpver)
---
### Helpful Notes ###
## Environment Variables
* A cron is set up in the container to backup the database every 15 minutes to your user's directory.
* If you want to restart the instance again, run ```docker start {name-of-your-container}``` in the example, *name-of-your-cintainer* is *local-dev*
* To stop a restarted instance, run ```docker stop {name-of-your-container}```
* To view log stream from container, run ```docker logs -f {name-of-your-container}```
* To delete a container, run ```docker rm {name-of-your-container}``` *__Note:__ this does not delete the files in user directory or database, as those are store in your system*
* To view running containers, run ```docker ps```
* To view all created containers, run ```docker ps --all``
* To view all container images downloaded on your system, run ```docker images```
**Required:**
- `uid` User ID for file permissions
- `user` Username for file permissions
- `domain` Primary domain for configuration
**Optional:**
- `environment` Set to `DEV` to start memcached and MySQL locally for development
- `serveralias` Comma-separated list of alternative hostnames
- `PHPVER` PHP version (see above)
---
## Helpful Notes
- To restart the instance: `./instance_start` or `docker start {container-name}`
- To stop: `./instance_stop` or `docker stop {container-name}`
- To view logs: `./instance_logs` or `docker logs -f {container-name}`
- To get DB credentials: `./instance_db_info` or `cat /home/$user/mysql_creds`
- To delete a container: `docker rm {container-name}` (does not delete user files or DB volume)
- To view running containers: `docker ps`
- To view all containers: `docker ps --all`
- To view images: `docker images`
---
## Troubleshooting
- The first run may take several minutes as dependencies are installed.
- If you need to change PHP version, stop and remove the container, then recreate with the desired version.
- For advanced configuration, see the scripts in the `scripts/` directory.
- The image is optimized for size and speed, but local development in DEV mode may install additional packages (MariaDB, memcached) at runtime using microdnf.
- The build context is minimized by the included `.dockerignore` file.

View File

@@ -2,12 +2,12 @@ DirectoryIndex index.html index.htm index.php
Alias "/ping" "/var/www/html"
<IfModule mpm_event_module>
StartServers 10
MinSpareThreads 25
MaxSpareThreads 75
StartServers 2
MinSpareThreads 10
MaxSpareThreads 25
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 800
ServerLimit 32
MaxConnectionsPerChild 1500
MaxRequestWorkers 75
ServerLimit 3
MaxConnectionsPerChild 1000
</IfModule>

View File

@@ -1,11 +1,11 @@
# MariaDB 10.11 CentOS repository list - created 2023-04-03 23:52 UTC
# MariaDB 11.4.5 CentOS repository list - created 2023-04-03 23:52 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/10.11/centos/$releasever/$basearch
baseurl = https://mirrors.xtom.com/mariadb/yum/10.11/centos/$releasever/$basearch
baseurl = https://mirror.mariadb.org/yum/11.4/almalinux$releasever-amd64
module_hotfixes = 1
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.xtom.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
gpgcheck = 1

View File

@@ -1091,7 +1091,7 @@ session.save_handler = memcache
; RPM note : session directory must be owned by process owner
; for mod_php, see /etc/httpd/conf.d/php.conf
; for php-fpm, see /etc/php-fpm.d/*conf
session.save_path = "tcp://localhost:11211"
session.save_path = "tcp://memcache:11211"
; Whether to use strict session mode.
; Strict session mode does not accept an uninitialized session ID, and

2
configs/remote_ip.conf Normal file
View File

@@ -0,0 +1,2 @@
RemoteIPHeader X-Forwarded-For
LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

View File

@@ -12,14 +12,17 @@ listen = /run/php-fpm/www.sock
listen.owner = apache
listen.group = apache
pm = static
pm.max_children = 10
pm.max_requests = 150
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500
slowlog = /etc/httpd/logs/error_log
request_slowlog_timeout = 3s
php_admin_value[error_log] = /etc/httpd/logs/error_log
php_admin_value[error_log] = /home/$user/logs/php-fpm/error.log
php_admin_flag[log_errors] = on
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache

View File

@@ -1,7 +1,11 @@
#!/usr/bin/env bash
if [ -z "$PHPVER" ]; then
PHPVER="81";
PHPVER="83";
fi
if [ -z "$environment" ]; then
environment="PROD"
fi
adduser -u $uid $user
@@ -14,7 +18,10 @@ mv /var/log/httpd /var/log/httpd.bak
ln -s /home/$user/logs/apache /var/log/httpd
ln -s /home/$user/logs/php-fpm /var/log/php-fpm
/scripts/install-php$PHPVER.sh
rm -f /etc/httpd/conf.d/userdir.conf
docker_network=$(ip addr show |grep eth0 |grep inet |awk -F " " {'print $2'})
echo "RemoteIPInternalProxy $docker_network" >> /etc/httpd/conf.d/remoteip.conf
# /scripts/install-php$PHPVER.sh
/scripts/create-vhost.sh
/scripts/create-php-config.sh
@@ -31,7 +38,13 @@ chmod -R 755 /home/$user
if [[ $environment == 'DEV' ]]; then
echo "Starting Dev Deployment"
mkdir -p /home/$user/_db_backups
dnf install -y MariaDB-server MariaDB-client memcached
# Ensure microdnf is available for installing MariaDB and memcached in DEV mode
if ! command -v microdnf &> /dev/null; then
echo "microdnf not found, installing with dnf..."
dnf install -y microdnf && dnf clean all
fi
microdnf install -y MariaDB-server MariaDB-client memcached
sed -r -i 's/session.save_path="memcache:11211/session.save_path="localhost:11211/' /etc/php.ini
nohup mysqld -umysql &
if [ ! -f /home/$user/mysql_creds ]; then
echo "Give MySQL a chance to finish starting..."
@@ -43,7 +56,10 @@ if [[ $environment == 'DEV' ]]; then
mysql -e "CREATE USER '"$mysql_user"'@'localhost' IDENTIFIED BY '"$mysql_password"';"
mysql -e "GRANT ALL PRIVILEGES ON *.* TO '"$mysql_user"'@'localhost' WITH GRANT OPTION;"
mysql -e "FLUSH PRIVILEGES;"
echo "*/15 * * * * root /scripts/mysql-backup.sh $user devdb_$mysql_db" >> /etc/crontab
# Create user crontab with MySQL backup job
echo "# User crontab for $user" > /home/$user/crontab
echo "*/15 * * * * /scripts/mysql-backup.sh $user devdb_$mysql_db" >> /home/$user/crontab
chown $user:$user /home/$user/crontab
echo "MySQL User: "$mysql_user > /home/$user/mysql_creds
echo "MySQL Password: "$mysql_password >> /home/$user/mysql_creds
echo "MySQL Database: devdb_"$mysql_db >> /home/$user/mysql_creds
@@ -57,6 +73,18 @@ fi
if [[ $environment == 'PROD' ]]; then
sed -r -i 's/;session.save_path="localhost:11211/session.save_path="memcache:11211/' /etc/php.d/50-memcached.ini
fi
# Set up user crontab
if [ ! -f /home/$user/crontab ]; then
echo "# User crontab for $user" > /home/$user/crontab
echo "# Add your cron jobs here" >> /home/$user/crontab
echo "# Example: */5 * * * * /home/$user/scripts/my-script.sh" >> /home/$user/crontab
chown $user:$user /home/$user/crontab
fi
# Load user crontab
crontab -u $user /home/$user/crontab
/usr/sbin/crond
tail -f /var/log/httpd/*

View File

@@ -2,5 +2,5 @@
dnf module enable php:remi-7.4 -y
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-xmlrpc \
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd libzip php-cli
php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd php-pgsql libzip php-cli
exit 0

View File

@@ -2,5 +2,5 @@
dnf module enable php:remi-8.0 -y
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd libzip php-cli
php-mysqlnd php-mbstring php-intl php-gd php-pgsql libzip php-cli
exit 0

View File

@@ -2,5 +2,5 @@
dnf module enable php:remi-8.1 -y
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd libzip php-cli
php-mysqlnd php-mbstring php-intl php-gd php-pgsql libzip php-cli
exit 0

View File

@@ -2,5 +2,5 @@
dnf module enable php:remi-8.2 -y
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
php-mysqlnd php-mbstring php-intl php-gd libzip php-cli
php-mysqlnd php-mbstring php-intl php-gd php-pgsql libzip php-cli
exit 0

View File

@@ -2,5 +2,5 @@
dnf module enable php:remi-8.3 -y
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
php-mysqlnd php-mbstring php-intl php-gd libzip php-cli
php-mysqlnd php-mbstring php-intl php-gd php-pgsql libzip php-cli
exit 0

6
scripts/install-php84.sh Normal file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
dnf module enable php:remi-8.4 -y
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
php-mysqlnd php-mbstring php-intl php-gd php-pgsql libzip php-cli
exit 0