Compare commits

...

18 Commits
v1.0 ... master

Author SHA1 Message Date
9fd3d7142d fixed the readme links 2025-03-26 18:19:10 -07:00
c185b80b4f updated name in docker-compose 2025-03-21 18:21:19 -07:00
9dcb385cf1 fix path 2025-03-21 17:42:30 -07:00
e6b9d42097 change name to corxn 2025-03-21 17:39:39 -07:00
0be607a1ae correct image 2025-03-21 13:22:29 -07:00
f59517b318 fixed up readme 2025-03-15 00:51:54 -07:00
c8021f204d php version 8.4.5 debian rebuild v6 2025-03-15 00:38:49 -07:00
125e461786 Fixed apache config 2025-01-14 18:53:28 -08:00
6d154446d3 v5.0.0 2025-01-14 17:05:44 -08:00
8684050d1d updated to version 4 with podman support 2024-07-18 13:40:36 -07:00
fa910780a3 added sample data and php.ini updated php version, did not build 2024-06-04 16:41:12 -07:00
29d84fe54f v3 2023-12-17 16:55:16 -08:00
2d544e1411 revert 95f8846e3dbde782c050e6b321221a920ec9bca6
revert updated for features

In the modified Dockerfile, I added the necessary dependencies (zlib1g-dev, libmemcached11) and modified the installation and enabling of the zip, memcached, and imagick extensions.
2023-12-17 15:53:50 -08:00
95f8846e3d updated for features
In the modified Dockerfile, I added the necessary dependencies (zlib1g-dev, libmemcached11) and modified the installation and enabling of the zip, memcached, and imagick extensions.
2023-12-17 00:10:05 -08:00
30487a87e9 now supports Joomla 2023-08-30 12:21:28 -07:00
2d4afd080e added gd and zip, solving issue #1 2023-08-23 12:55:00 -07:00
35a35196e5 moved documentation to wiki 2023-08-23 09:57:25 -07:00
1db0abeb49 added dockerhub url 2023-08-23 09:54:57 -07:00
8 changed files with 349 additions and 47 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
data/

16
000-default.conf Normal file
View File

@ -0,0 +1,16 @@
# Global log redirection to stdout and stderr
ErrorLog "|/usr/bin/tee -a /var/log/apache2/error.log"
CustomLog "|/usr/bin/tee -a /var/log/apache2/access.log" combined
<VirtualHost *:80>
DocumentRoot /data/public
<Directory /data/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Remote IP configuration
RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 127.0.0.1
</VirtualHost>

View File

@ -1,45 +1,53 @@
########################################################################################################################################
# Documentation: https://git.nickyeoman.com/4lt/phpcontainer/wiki
########################################################################################################################################
FROM php:8.2.9-apache
LABEL maintainer="4 Lights Consulting <info@4lt.ca>"
LABEL description="Production-ready PHP Apache container"
LABEL version="1"
LABEL org.label-schema.vcs-url="https://git.nickyeoman.com/4lt/phpcontainer"
FROM debian:bookworm-20250224
# Setup
WORKDIR /website
ENV APACHE_DOCUMENT_ROOT /website/public/
WORKDIR /data
# APT
RUN apt-get update
# Install necessary packages and configure PHP repository
RUN apt-get update && apt-get install -y \
lsb-release ca-certificates curl apt-transport-https logrotate ssl-cert apache2 && \
echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb && \
dpkg -i /tmp/debsuryorg-archive-keyring.deb && \
sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' && \
apt-get update && \
apt-get install -y \
php8.4 php8.4-cli php8.4-fpm php8.4-mysql php8.4-xml php8.4-mbstring php8.4-curl php8.4-zip php8.4-redis libapache2-mod-php8.4 && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/*
# IMAP
RUN apt-get install -y libc-client-dev libkrb5-dev libssl-dev;
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
RUN docker-php-ext-install imap
# log management
RUN cat <<EOF > /etc/logrotate.d/apache2
/var/log/apache2/*.log {
weekly
missingok
rotate 4
compress
delaycompress
notifempty
create 640 root adm
}
EOF
# Symfony
RUN apt-get install -y libicu-dev
RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl
RUN echo 'RemoteIPHeader X-Forwarded-For' > /etc/apache2/conf-available/remoteip.conf && \
echo 'RemoteIPTrustedProxy 127.0.0.1' >> /etc/apache2/conf-available/remoteip.conf && \
a2enconf remoteip && \
sed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' /etc/apache2/*.conf
# Cleanup
RUN rm -r /var/lib/apt/lists/*
RUN mkdir -p /php && echo "PHP_INI_SCAN_DIR=/php" > /etc/environment
COPY php.ini /php/php.ini
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
# Apache settings
# Security headers for Apache
RUN echo 'Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"' >> /etc/apache2/conf-available/security.conf && \
echo 'Header always set X-Content-Type-Options "nosniff"' >> /etc/apache2/conf-available/security.conf && \
echo 'Header always set X-XSS-Protection "1; mode=block"' >> /etc/apache2/conf-available/security.conf && \
echo 'Header always set X-Frame-Options "SAMEORIGIN"' >> /etc/apache2/conf-available/security.conf
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN a2enmod expires headers rewrite socache_shmcb ssl
RUN docker-php-ext-install mysqli pdo pdo_mysql
RUN docker-php-ext-install opcache
# Docker config
RUN a2enmod expires headers rewrite remoteip socache_shmcb ssl
EXPOSE 80
CMD ["apache2-foreground"]
CMD ["apachectl", "-D", "FOREGROUND"]
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD curl --silent --fail localhost:80 || exit 1

View File

@ -1,16 +1,44 @@
# 4 Lights Consulting
![CORXN Container](/_assets/corxn-logo.png)
The apache php docker container that we use for production.
# CORXN - The Core Foundation of Novaconium
User Documentation: https://git.nickyeoman.com/4lt/phpcontainer/wiki
Links: [Dockerhub](https://hub.docker.com/r/4lights/corxn), [Git Repo](https://git.4lt.ca/4lt/CORXN)
## Development Documentation
CORXN (core-ex-en) is a lightweight yet powerful Docker-based environment designed as the core foundation for the [Novaconium PHP Framework](https://git.4lt.ca/4lt/novaconium).
It provides a streamlined stack featuring Apache, the latest PHP version, Redis, and MariaDB, optimized for high performance.
You might have to login with your api key.
## Features
- **PHP Version**: 8.4.5
- **Apache Web Server**: Configured to run PHP applications
- **Support for**:
- `remoteip` (reverse proxy)
- `redis`
- `mariadb`
- **Timezone**: Default set to Vancouver (`America/Vancouver`)
## Getting Started
Follow these steps to set up the PHP container on your local environment.
### Usage
#### Clone the Repository
```bash
git clone https://git.4lt.ca/4lt/corxn.git
cd corxn
```
sudo docker build -t phpcontainer:1 .
sudo docker tag phpcontainer:1 4lights/phpcontainer:v1
sudo docker tag phpcontainer:1 4lights/phpcontainer:latest
sudo docker push 4lights/phpcontainer:v1
sudo docker push 4lights/phpcontainer:latest
```
## How to update image on dockerhub
```bash
sudo su
docker buildx build --no-cache -t 4lights/corxn:6.0.0 -t 4lights/corxn:latest --load .
docker login
docker push 4lights/corxn:6.0.0
docker push 4lights/corxn:latest
```
# References And Notes
Test using test.php

BIN
_assets/corxn-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

39
docker-compose.yml Normal file
View File

@ -0,0 +1,39 @@
# Sample Docker Compose
services:
corxn:
image: 4lights/corxn:6.0.0
ports:
- "8000:80"
volumes:
- ./:/data # looks for /data/public
- ./php.ini:/php/php.ini # Optional override php.ini
- ./data/logs:/var/log/apache2 # Optional Logs
restart: unless-stopped
networks:
- proxy
- internal
redis:
image: redis:latest
networks:
- internal
restart: unless-stopped
mariadb:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: dbname
MYSQL_USER: user
MYSQL_PASSWORD: password
volumes:
- ./data/db:/var/lib/mysql
networks:
- internal
restart: unless-stopped
networks:
proxy:
external: true
internal:
driver: bridge

55
php.ini Normal file
View File

@ -0,0 +1,55 @@
[PHP]
; Basic PHP settings
max_execution_time = 30
memory_limit = 500M
upload_max_filesize = 100M
post_max_size = 100M
max_input_time = 60
date.timezone = America/Vancouver
; Error handling
display_errors = On
display_startup_errors = On
log_errors = On
error_log = /var/log/php_errors.log
; Session settings
session.save_path = "/var/lib/php/sessions"
session.gc_maxlifetime = 1440
session.cookie_lifetime = 0
session.use_strict_mode = 1
; Realpath cache
realpath_cache_size = 4096k
realpath_cache_ttl = 120
; File upload settings
file_uploads = On
allow_url_fopen = On
; Redis settings (ensure Redis extension is loaded)
extension=redis.so
; mbstring settings (useful for multi-byte encoding handling)
mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.http_output = UTF-8
mbstring.detect_order = auto
mbstring.substitute_character = none
; cURL settings
curl.cainfo = "/etc/ssl/certs/ca-certificates.crt"
; SMTP settings (for sending mail, if needed)
SMTP = localhost
sendmail_path = /usr/sbin/sendmail -t -i
; Extension loading
extension=curl
extension=mbstring
extension=redis
extension=xml
extension=mysqli
extension=pdo_mysql
extension=zip

155
public/test.php Normal file
View File

@ -0,0 +1,155 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Server Test - Debian PHP Apache</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
color: #333;
margin: 20px;
padding: 20px;
}
h2 {
color: #0056b3;
border-bottom: 2px solid #0056b3;
padding-bottom: 5px;
}
p {
background: #fff;
padding: 10px;
border-radius: 5px;
box-shadow: 0px 1px 3px rgba(0,0,0,0.1);
}
.container {
max-width: 700px;
margin: auto;
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
background: #fff;
}
table, th, td {
border: 1px solid #ddd;
}
th, td {
padding: 10px;
text-align: left;
}
th {
background: #0056b3;
color: white;
}
.upload-section {
background: #e3f2fd;
padding: 15px;
border-radius: 5px;
margin-top: 20px;
}
.upload-section input[type="file"] {
padding: 5px;
}
.upload-section input[type="submit"] {
background: #0056b3;
color: white;
border: none;
padding: 8px 12px;
border-radius: 5px;
cursor: pointer;
}
.upload-section input[type="submit"]:hover {
background: #003d80;
}
</style>
</head>
<body>
<div class="container">
<h1>PHP Container Test Script</h1>
<p><a href="https://git.4lt.ca/4lt/phpcontainer">Four Lights PHP Container</a></p>
<h2>Server Information</h2>
<table>
<tr><th>PHP Version</th><td><?php echo phpversion(); ?></td></tr>
<tr><th>Current Date/Time (Vancouver)</th><td><?php date_default_timezone_set('America/Vancouver'); echo date('Y-m-d H:i:s'); ?></td></tr>
<tr><th>upload_max_filesize</th><td><?php echo ini_get('upload_max_filesize'); ?></td></tr>
<tr><th>post_max_size</th><td><?php echo ini_get('post_max_size'); ?></td></tr>
<tr><th>php.ini</th><td><?php echo php_ini_loaded_file(); ?></td></tr>
</table>
<h2>Redis Test</h2>
<?php
$redis = new Redis();
try {
$redis->connect('redis', 6379);
echo "<p>✅ Redis connected</p>";
$redis->set("test_key", "There are FOUR Lights!");
echo "<p>Redis test_key: " . $redis->get("test_key") . "</p>";
} catch (Exception $e) {
echo "<p>❌ Redis connection failed: " . $e->getMessage() . "</p>";
}
?>
<h2>MariaDB Test</h2>
<?php
$mysqli = new mysqli('mariadb', 'user', 'password', 'dbname');
if ($mysqli->connect_error) {
echo "<p>❌ MariaDB connection failed: " . $mysqli->connect_error . "</p>";
} else {
echo "<p>✅ MariaDB connected</p>";
$result = $mysqli->query('SELECT NOW()');
$row = $result->fetch_row();
echo "<p>Current time in MariaDB: " . $row[0] . "</p>";
$mysqli->close();
}
?>
<h2>RemoteIP Test</h2>
<p>Your IP address (from Apache's remoteip module): <?php echo $_SERVER['REMOTE_ADDR']; ?></p>
<h2>File Upload Test</h2>
<div class="upload-section">
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="testfile">
<input type="submit" name="upload" value="Upload">
</form>
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['testfile'])) {
if ($_FILES['testfile']['error'] === UPLOAD_ERR_OK) {
$uploadDir = '/data/public/uploads/';
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
$destination = $uploadDir . basename($_FILES['testfile']['name']);
if (move_uploaded_file($_FILES['testfile']['tmp_name'], $destination)) {
echo "<p>✅ File uploaded successfully to: <strong>" . htmlspecialchars($destination) . "</strong></p>";
echo "<p>Size: " . $_FILES['testfile']['size'] . " bytes</p>";
} else {
echo "<p>❌ Error moving file.</p>";
}
} else {
echo "<p>❌ Error uploading file. Error Code: " . $_FILES['testfile']['error'] . "</p>";
}
}
?>
</div>
</body>
</html>