Compare commits

..

34 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
jknapp
aab89a7412 Merge pull request 'Update for log rotation and backups' (#14) from log-cleanup into trunk
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 1m22s
Reviewed-on: #14
2024-10-15 02:32:44 +00:00
527ba5cf58 Adding better backups and log rotation, and updating files around it 2024-10-14 19:30:51 -07:00
bbd2de6792 Update for log rotation and backups 2024-10-14 12:15:11 -07:00
jknapp
ed9ba0118b Update to reflect changes for user directory
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 41s
2024-10-14 17:28:24 +00:00
jknapp
715b998404 Update README to reflect gitea address and adding logs
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 1m22s
2024-10-14 17:25:10 +00:00
jknapp
7d988b338c Merge pull request 'Fixing script to add more time for startup and add backup crons for database' (#13) from fix-script into trunk
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 34s
Reviewed-on: #13
2024-10-02 20:22:22 +00:00
b3e284a547 Fixing script to add more time for startup and add backup crons for database 2024-10-02 13:21:49 -07:00
jknapp
565482764d Merge pull request 'Update script to default to PHP 8.3 and have options' (#12) from add-php83 into trunk
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 32s
Reviewed-on: #12
2024-10-02 18:55:46 +00:00
3d3e353c66 Update script to default to PHP 8.3 and have options 2024-10-02 11:55:22 -07:00
23 changed files with 466 additions and 180 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: jobs:
Build-and-Push: Build-and-Push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
phpver: [74, 80, 81, 82, 83, 84]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -16,19 +19,22 @@ jobs:
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to Gitea - name: Login to Gitea
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: repo.anhonesthost.net registry: repo.anhonesthost.net
username: ${{ secrets.CI_USER }} username: ${{ secrets.CI_USER }}
password: ${{ secrets.CI_TOKEN }} password: ${{ secrets.CI_TOKEN }}
- name: Build Image - name: Build and Push Image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
platforms: linux/amd64 platforms: linux/amd64
push: true push: true
build-args: |
PHPVER=${{ matrix.phpver }}
tags: | 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 FROM almalinux/9-base
ARG PHPVER=81 ARG PHPVER=83
#RUN dnf update -y && dnf upgrade -y
RUN dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y # Install repos, update, install only needed packages, clean up in one layer
RUN dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm RUN dnf install -y \
#RUN dnf update -y && dnf upgrade -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm \
RUN dnf install -y httpd mod_ssl wget procps https://rpms.remirepo.net/enterprise/remi-release-9.rpm && \
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 dnf update -y && \
RUN mkdir /run/php-fpm/ dnf install -y httpd mod_ssl wget procps cronie iproute postgresql-devel microdnf less git \
RUN mkdir /scripts nano rsync unzip zip mariadb bind-utils jq patch nc tree dos2unix && \
COPY ./scripts/* /scripts/ 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 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 # Generate self-signed cert, create needed dirs, install PHP, clean up
RUN chmod +x wp-cli.phar 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 mv wp-cli.phar /usr/local/bin/wp 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/default-index.conf /etc/httpd/conf.d/
COPY ./configs/prod-php.ini /etc/php.ini COPY ./configs/prod-php.ini /etc/php.ini
COPY ./configs/phpinfo.php /var/www/html/ COPY ./configs/phpinfo.php /var/www/html/
COPY ./configs/mariadb.repo /etc/yum.repos.d/ COPY ./configs/mariadb.repo /etc/yum.repos.d/
COPY ./configs/index.php /var/www/html/ COPY ./configs/index.php /var/www/html/
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" ] ENTRYPOINT [ "/scripts/entrypoint.sh" ]

152
README.md
View File

@@ -1,72 +1,134 @@
# Cloud Apache Container # # 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
*__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:__ **Flags:**
*Note this is an example, you can modify the command(s) to fit your needs.* - `-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 mkdir -p local-development/domain.tld
cd local-development/domain.tld cd local-development/domain.tld
mkdir {web,db} mkdir user
docker run -it -p 80:80 -p 443:443 -e PHPVER=81 -e environment=DEV --mount type=bind,source="$(pwd)"/web,target=/home/myuser/public_html --mount type=bind,source="$(pwd)"/db,target=/var/lib/mysql -e uid=30001 -e user=myuser -e domain=domain.tld -e serveralias=www.domain.tld --name local-dev public.ecr.aws/s1f6k4w4/cac:latest mkdir -p user/logs/{apache,system}
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:__ ```bash
```console
docker exec -it local-dev /bin/bash docker exec -it local-dev /bin/bash
``` ```
__To install WordPress for your site__ ---
```console ## WordPress Installation
cat /var/lib/mysql/creds
If using `local-dev.sh`, WordPress is installed automatically. For manual setup:
```bash
cat /home/myuser/mysql_creds
su - myuser su - myuser
cd ~/public_html cd ~/public_html
wp core download 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 /var/lib/mysql/creds file, which we had *cat* in the commands above. ---
### PHPVER ### ## Features
*74* - PHP 7.4
*80* - PHP 8.0
*81* - PHP 8.1
*82* - PHP 8.2
*83* - PHP 8.3
### Environment Variables ### - **Multiple PHP Versions:** 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 (set with `PHPVER` or `-a` flag)
__Required Tags__ - **Pre-built Images:** Pull the image for your desired PHP version directly from the registry. No need to build locally unless customizing.
*uid* - User ID for File Permissions - **Optimized Build:** Smaller, faster, and more secure images thanks to the improved Dockerfile and `.dockerignore`.
*user* - Username for File Permissions - **Automatic Database Setup:** MariaDB is started in DEV mode, credentials are auto-generated and stored in `/home/$user/mysql_creds`.
*domain* - Primary Domain for configuration - **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
* On your first creation of a dev instance, you will be dumped to the logs output. Hit ```ctrl + c``` to exit the running process. **Required:**
* 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* - `uid` User ID for file permissions
* To stop a restarted instance, run ```docker stop {name-of-your-container}``` - `user` Username for file permissions
* To view log stream from container, run ```docker logs -f {name-of-your-container}``` - `domain` Primary domain for configuration
* To delete a container, run ```docker rm {name-of-your-container}``` *__Note:__ this does not delete the files in public_html or database, as those are store in your system*
* To view running containers, run ```docker ps``` **Optional:**
* To view all created containers, run ```docker ps --all`` - `environment` Set to `DEV` to start memcached and MySQL locally for development
* To view all container images downloaded on your system, run ```docker images``` - `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" Alias "/ping" "/var/www/html"
<IfModule mpm_event_module> <IfModule mpm_event_module>
StartServers 10 StartServers 2
MinSpareThreads 25 MinSpareThreads 10
MaxSpareThreads 75 MaxSpareThreads 25
ThreadLimit 64 ThreadLimit 64
ThreadsPerChild 25 ThreadsPerChild 25
MaxRequestWorkers 800 MaxRequestWorkers 75
ServerLimit 32 ServerLimit 3
MaxConnectionsPerChild 1500 MaxConnectionsPerChild 1000
</IfModule> </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/ # https://mariadb.org/download/
[mariadb] [mariadb]
name = MariaDB name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details. # 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://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 module_hotfixes = 1
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB # gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.xtom.com/mariadb/yum/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 ; RPM note : session directory must be owned by process owner
; for mod_php, see /etc/httpd/conf.d/php.conf ; for mod_php, see /etc/httpd/conf.d/php.conf
; for php-fpm, see /etc/php-fpm.d/*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. ; Whether to use strict session mode.
; Strict session mode does not accept an uninitialized session ID, and ; 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

@@ -40,6 +40,42 @@
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost> </VirtualHost>
#
# When we also provide SSL we have to listen to the
# standard HTTPS port in addition.
#
Listen 443 https
##
## SSL Global Context
##
## All SSL configuration in this context applies both to
## the main server and all SSL-enabled virtual hosts.
##
# Pass Phrase Dialog:
# Configure the pass phrase gathering process.
# The filtering dialog program (`builtin' is a internal
# terminal dialog) has to provide the pass phrase on stdout.
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog
# Inter-Process Session Cache:
# Configure the SSL Session Cache: First the mechanism
# to use and second the expiring timeout (in seconds).
SSLSessionCache shmcb:/run/httpd/sslcache(512000)
SSLSessionCacheTimeout 300
#
# Use "SSLCryptoDevice" to enable any supported hardware
# accelerators. Use "openssl engine -v" to list supported
# engine names. NOTE: If you enable an accelerator and the
# server does not start, consult the error logs and ensure
# your accelerator is functioning properly.
#
SSLCryptoDevice builtin
<IfModule mod_ssl.c> <IfModule mod_ssl.c>
<VirtualHost _default_:443> <VirtualHost _default_:443>
ServerName "~~domain~~" ServerName "~~domain~~"

View File

@@ -5,18 +5,20 @@ https_port='443'
root_path="$(pwd)" root_path="$(pwd)"
verbose='false' verbose='false'
while getopts 'n:p:s:r:vh' flag; do while getopts 'n:p:s:r:a:vh' flag; do
case "${flag}" in case "${flag}" in
n) name="${OPTARG}" ;; n) name="${OPTARG}" ;;
p) http_port="${OPTARG}" ;; p) http_port="${OPTARG}" ;;
s) https_port="${OPTARG}" ;; s) https_port="${OPTARG}" ;;
r) root_path="${OPTARG}" ;; r) root_path="${OPTARG}" ;;
a) phpver="${OPTARG}" ;;
v) verbose='true' ;; v) verbose='true' ;;
h) echo "Variables" h) echo "Variables"
echo "-n = Name of Container, Required" echo "-n = Name of Container, Required"
echo "-p = Non-https Port Override, default 80" echo "-p = Non-https Port Override, default 80"
echo "-s = Https Port Override, default 443" echo "-s = Https Port Override, default 443"
echo "-r = Root Path for files and database, defaults to current working path" echo "-r = Root Path for files and database, defaults to current working path"
echo "-a = PHP App Version, Default to 8.3"
echo "-v = Enable Verbose Mode" echo "-v = Enable Verbose Mode"
exit 1 ;; exit 1 ;;
esac esac
@@ -34,16 +36,20 @@ if [ -z "$name" ]; then
echo "Name not set, please set it with -n" echo "Name not set, please set it with -n"
exit 1 exit 1
fi fi
if [ -z "$phpver" ]; then
phpver=83;
fi
echo "Building Docker Image..." echo "Building Docker Image..."
user=$(whoami) user=$(whoami)
uid=$(id -u) uid=$(id -u)
if [ ! -d "$root_path/db" ]; then if [ ! -d "$root_path/user" ]; then
mkdir -p "$root_path/db"; mkdir -p "$root_path/user";
mkdir -p "$root_path/user/logs/{apache,system}";
fi fi
if [ ! -d "$root_path/web" ]; then $check_docker volume create "$name-mysql"
mkdir -p "$root_path/web"; $check_docker run --pull=always -d -p "$http_port":80 -p "$https_port":443 -e PHPVER=$phpver -e environment=DEV --mount type=bind,source="$root_path"/user,target=/home/"$user" --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="$uid" -e user="$user" -e domain="$name-local.dev" --name "$name" repo.anhonesthost.net/cloud-hosting-platform/cac:latest
fi
$check_docker run -d -p "$http_port":80 -p "$https_port":443 -e PHPVER=82 -e environment=DEV --mount type=bind,source="$root_path"/web,target=/home/"$user"/public_html --mount type=bind,source="$root_path"/db,target=/var/lib/mysql -e uid="$uid" -e user="$user" -e domain="$name-local.dev" --name "$name" repo.anhonesthost.net/cloud-hosting-platform/cac:latest
echo "Creating management scripts in root directory..." echo "Creating management scripts in root directory..."
echo "#!/usr/bin/env bash" > "$root_path/instance_start" echo "#!/usr/bin/env bash" > "$root_path/instance_start"
echo "docker start $name" >> "$root_path/instance_start" echo "docker start $name" >> "$root_path/instance_start"
@@ -54,8 +60,8 @@ echo "docker exec $name bash -c 'tail -f /etc/httpd/logs/*'" >> "$root_path/inst
echo "#!/usr/bin/env bash" > "$root_path/instance_db_info" echo "#!/usr/bin/env bash" > "$root_path/instance_db_info"
echo "docker exec $name cat /var/lib/mysql/creds" >> "$root_path/instance_db_info" echo "docker exec $name cat /var/lib/mysql/creds" >> "$root_path/instance_db_info"
chmod +x $root_path/instance_* chmod +x $root_path/instance_*
echo "Waiting 120 seconds for setup to finish" echo "Waiting 160 seconds for setup to finish"
sleep 120; sleep 160;
echo "Installing WordPress..." echo "Installing WordPress..."
wpdbuser=$(docker exec $name cat /var/lib/mysql/creds |grep User| awk -F ": " {'print $2'}) wpdbuser=$(docker exec $name cat /var/lib/mysql/creds |grep User| awk -F ": " {'print $2'})
wpdbpass=$(docker exec $name cat /var/lib/mysql/creds |grep Password| awk -F ": " {'print $2'}) wpdbpass=$(docker exec $name cat /var/lib/mysql/creds |grep Password| awk -F ": " {'print $2'})

View File

@@ -1,70 +0,0 @@
---
resources:
- name: cac
type: git
source:
uri: https://repo.anhonesthost.net/cloud-hosting-platform/cloud-apache-container.git
branch: trunk
- name: build-cac-74
type: docker-image
source:
repository: registry.dnspegasus.net/cac
tag: 74
- name: build-cac-80
type: docker-image
source:
repository: registry.dnspegasus.net/cac
tag: 80
- name: build-cac-81
type: docker-image
source:
repository: registry.dnspegasus.net/cac
tag: 81
- name: build-cac-82
type: docker-image
source:
repository: registry.dnspegasus.net/cac
tag: 82
jobs:
- name: publish-cac-74
plan:
- get: cac
trigger: true
- put: build-cac-74
params:
build: cac
build_args:
PHPVER: 74
- name: publish-cac-80
plan:
- get: cac
trigger: true
- put: build-cac-80
params:
build: cac
build_args:
PHPVER: 80
- name: publish-cac-81
plan:
- get: cac
trigger: true
- put: build-cac-81
params:
build: cac
build_args:
PHPVER: 81
- name: publish-cac-82
plan:
- get: cac
trigger: true
- put: build-cac-82
params:
build: cac
build_args:
PHPVER: 82

View File

@@ -12,14 +12,17 @@ listen = /run/php-fpm/www.sock
listen.owner = apache listen.owner = apache
listen.group = apache listen.group = apache
pm = static pm = dynamic
pm.max_children = 10 pm.max_children = 5
pm.max_requests = 150 pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500
slowlog = /etc/httpd/logs/error_log slowlog = /etc/httpd/logs/error_log
request_slowlog_timeout = 3s 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_admin_flag[log_errors] = on
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache

View File

@@ -34,6 +34,12 @@ cat <<EOF > /etc/httpd/conf.d/$domain.conf
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost> </VirtualHost>
Listen 443 https
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog
SSLSessionCache shmcb:/run/httpd/sslcache(512000)
SSLSessionCacheTimeout 300
SSLCryptoDevice builtin
<IfModule mod_ssl.c> <IfModule mod_ssl.c>
<VirtualHost _default_:443> <VirtualHost _default_:443>
ServerName "$domain" ServerName "$domain"

View File

@@ -1,29 +1,52 @@
#!/bin/bash #!/usr/bin/env bash
if [ -z "$PHPVER" ]; then if [ -z "$PHPVER" ]; then
PHPVER="81"; PHPVER="83";
fi
if [ -z "$environment" ]; then
environment="PROD"
fi fi
adduser -u $uid $user adduser -u $uid $user
mkdir -p /home/$user/public_html mkdir -p /home/$user/public_html
mkdir -p /home/$user/logs/{apache,php-fpm}
chown -R $user:$user /home/$user mv /var/log/httpd /var/log/httpd.bak
chmod -R 755 /home/$user
/scripts/install-php$PHPVER.sh ln -s /home/$user/logs/apache /var/log/httpd
ln -s /home/$user/logs/php-fpm /var/log/php-fpm
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-vhost.sh
/scripts/create-php-config.sh /scripts/create-php-config.sh
if [ -f /etc/httpd/conf.d/ssl.conf ]; then
mv /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.bak
fi
/usr/sbin/httpd -k start /usr/sbin/httpd -k start
/usr/sbin/php-fpm -y /etc/php-fpm.conf /usr/sbin/php-fpm -y /etc/php-fpm.conf
chown -R $user:$user /home/$user
chmod -R 755 /home/$user
if [[ $environment == 'DEV' ]]; then if [[ $environment == 'DEV' ]]; then
echo "Starting Dev Deployment" echo "Starting Dev Deployment"
dnf install -y MariaDB-server MariaDB-client memcached mkdir -p /home/$user/_db_backups
# 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 & nohup mysqld -umysql &
if [ ! -f /var/lib/mysql/creds ]; then if [ ! -f /home/$user/mysql_creds ]; then
echo "Give MySQL a chance to finish starting..." echo "Give MySQL a chance to finish starting..."
sleep 10 sleep 10
mysql_user=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13 ; echo '') mysql_user=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13 ; echo '')
@@ -33,19 +56,37 @@ if [[ $environment == 'DEV' ]]; then
mysql -e "CREATE USER '"$mysql_user"'@'localhost' IDENTIFIED BY '"$mysql_password"';" 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 "GRANT ALL PRIVILEGES ON *.* TO '"$mysql_user"'@'localhost' WITH GRANT OPTION;"
mysql -e "FLUSH PRIVILEGES;" mysql -e "FLUSH PRIVILEGES;"
echo "MySQL User: "$mysql_user > /var/lib/mysql/creds # Create user crontab with MySQL backup job
echo "MySQL Password: "$mysql_password >> /var/lib/mysql/creds echo "# User crontab for $user" > /home/$user/crontab
echo "MySQL Database: devdb_"$mysql_db >> /var/lib/mysql/creds echo "*/15 * * * * /scripts/mysql-backup.sh $user devdb_$mysql_db" >> /home/$user/crontab
cat /var/lib/mysql/creds 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
cat /home/$user/mysql_creds
fi fi
/usr/bin/memcached -d -u $user /usr/bin/memcached -d -u $user
fi fi
if [[ $environment == 'PROD' ]]; then if [[ $environment == 'PROD' ]]; then
sed -r -i 's/;session.save_path="localhost:11211/session.save_path="memcache:11211/' /etc/php.d/50-memcached.ini sed -r -i 's/;session.save_path="localhost:11211/session.save_path="memcache:11211/' /etc/php.d/50-memcached.ini
fi fi
tail -f /etc/httpd/logs/* # 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/*
exit 0 exit 0

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
dnf module enable php:remi-7.4 -y 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 \ 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-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 exit 0

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
dnf module enable php:remi-8.0 -y 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 \ 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-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 exit 0

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
dnf module enable php:remi-8.1 -y 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 \ 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-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 exit 0

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
dnf module enable php:remi-8.2 -y 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 \ 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-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 exit 0

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
dnf module enable php:remi-8.3 -y 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 \ 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-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 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

26
scripts/log-rotate.sh Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Set the log directory
LOG_DIR="/var/log/httpd"
# Get current date
DATE=$(date +%Y%m%d)
# Rotate access log
if [ -f "$LOG_DIR/access_log" ]; then
cp "$LOG_DIR/access_log" "$LOG_DIR/access_log.$DATE"
cat /dev/null > "$LOG_DIR/access_log"
fi
# Rotate error log
if [ -f "$LOG_DIR/error_log" ]; then
cp "$LOG_DIR/error_log" "$LOG_DIR/error_log.$DATE"
cat /dev/null > "$LOG_DIR/error_log"
fi
# Compress logs older than 3 days
find "$LOG_DIR" -name "*.log.*" -type f -mtime +3 -exec gzip {} \;
# Delete logs older than 7 days
find "$LOG_DIR" -name "*.log.*" -type f -mtime +7 -delete

14
scripts/mysql-backup.sh Normal file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
user=$1
mysql_db=$2
dt=$(date +%y%m%d-%T)
if [ ! -d /home/$user/_db_backups ]; then
mkdir -p /home/$user/_db_backups
fi
/usr/bin/mysqldump $mysql_db > /home/$user/_db_backups/$mysql_db.$dt.sql
chown -R $user:$user /home/$user/_db_backups
/usr/bin/find /home/$user/_db_backups/ -type f -mmin +360 -delete
exit 0