Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 546c49767f | |||
| a5deb07a66 | |||
| 9fd3d7142d | |||
| c185b80b4f | |||
| 9dcb385cf1 | |||
| e6b9d42097 | |||
| 0be607a1ae | |||
| f59517b318 | |||
| c8021f204d | |||
| 125e461786 | |||
| 6d154446d3 | |||
| 8684050d1d | |||
| fa910780a3 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
data/
|
||||||
22
000-default.conf
Normal file
22
000-default.conf
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName localhost
|
||||||
|
|
||||||
|
DocumentRoot /data/public
|
||||||
|
|
||||||
|
<Directory /data/public>
|
||||||
|
Options FollowSymLinks
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
DirectoryIndex index.php index.html
|
||||||
|
|
||||||
|
# PHP-FPM handler
|
||||||
|
<FilesMatch \.php$>
|
||||||
|
SetHandler "proxy:unix:/run/php/php8.5-fpm.sock|fcgi://localhost/"
|
||||||
|
</FilesMatch>
|
||||||
|
|
||||||
|
# Docker-friendly logging
|
||||||
|
ErrorLog /proc/self/fd/2
|
||||||
|
CustomLog /proc/self/fd/1 combined
|
||||||
|
</VirtualHost>
|
||||||
250
Dockerfile
250
Dockerfile
@@ -1,148 +1,120 @@
|
|||||||
########################################################################################################################################
|
FROM debian:trixie-20260316
|
||||||
# Documentation: https://git.4lt.ca/4lt/phpcontainer/wiki
|
|
||||||
# v3.0
|
|
||||||
#################################################################################################################################
|
|
||||||
|
|
||||||
# Use the PHP base image
|
|
||||||
FROM php:8.3.0-apache
|
|
||||||
|
|
||||||
# Set maintainer information
|
|
||||||
LABEL version="3"
|
|
||||||
LABEL maintainer="4 Lights Consulting <info@4lt.ca>"
|
|
||||||
LABEL description="Production-ready PHP Apache container"
|
|
||||||
LABEL org.label-schema.vcs-url="https://git.nickyeoman.com/4lt/phpcontainer"
|
|
||||||
|
|
||||||
# Set working directory and Apache document root
|
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
ENV APACHE_DOCUMENT_ROOT /data/public/
|
|
||||||
|
|
||||||
# Install required packages
|
# Install base packages + Apache + PHP repo
|
||||||
RUN set -eux; \
|
RUN apt-get update && apt-get install -y \
|
||||||
apt-get update && \
|
lsb-release \
|
||||||
apt-get install -y --no-install-recommends ghostscript;
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
logrotate \
|
||||||
|
ssl-cert \
|
||||||
|
apache2 \
|
||||||
|
&& echo "ServerName localhost" >> /etc/apache2/apache2.conf \
|
||||||
|
\
|
||||||
|
# Add Sury PHP repo
|
||||||
|
&& curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb \
|
||||||
|
&& dpkg -i /tmp/debsuryorg-archive-keyring.deb \
|
||||||
|
&& 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 \
|
||||||
|
\
|
||||||
|
# Install PHP 8.5 + extensions
|
||||||
|
&& apt-get install -y \
|
||||||
|
php8.5 \
|
||||||
|
php8.5-cli \
|
||||||
|
php8.5-fpm \
|
||||||
|
php8.5-mysql \
|
||||||
|
php8.5-xml \
|
||||||
|
php8.5-mbstring \
|
||||||
|
php8.5-curl \
|
||||||
|
php8.5-zip \
|
||||||
|
php8.5-redis \
|
||||||
|
\
|
||||||
|
# Cleanup
|
||||||
|
&& apt-get autoremove -y \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* /tmp/*
|
||||||
|
|
||||||
# IMAP
|
# Apache + PHP-FPM configuration + performance tuning
|
||||||
RUN apt-get install -y libc-client-dev libkrb5-dev libssl-dev;
|
RUN \
|
||||||
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl
|
# Enable modules
|
||||||
RUN docker-php-ext-install imap
|
a2enmod proxy_fcgi setenvif expires headers rewrite remoteip socache_shmcb ssl deflate \
|
||||||
|
\
|
||||||
|
# Switch to MPM event
|
||||||
|
&& a2dismod mpm_prefork \
|
||||||
|
&& a2enmod mpm_event \
|
||||||
|
\
|
||||||
|
# Enable PHP-FPM
|
||||||
|
&& a2enconf php8.5-fpm \
|
||||||
|
\
|
||||||
|
# Remote IP config
|
||||||
|
&& 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 \
|
||||||
|
\
|
||||||
|
# Security headers
|
||||||
|
&& 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-Frame-Options "SAMEORIGIN"' >> /etc/apache2/conf-available/security.conf \
|
||||||
|
\
|
||||||
|
# Compression
|
||||||
|
&& echo 'AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json' > /etc/apache2/conf-available/compression.conf \
|
||||||
|
&& a2enconf compression \
|
||||||
|
\
|
||||||
|
# KeepAlive tuning
|
||||||
|
&& cat <<EOF > /etc/apache2/conf-available/keepalive.conf
|
||||||
|
KeepAlive On
|
||||||
|
MaxKeepAliveRequests 100
|
||||||
|
KeepAliveTimeout 2
|
||||||
|
EOF \
|
||||||
|
&& a2enconf keepalive \
|
||||||
|
\
|
||||||
|
# MPM Event tuning
|
||||||
|
&& cat <<EOF > /etc/apache2/conf-available/mpm-event-tuning.conf
|
||||||
|
<IfModule mpm_event_module>
|
||||||
|
StartServers 2
|
||||||
|
MinSpareThreads 25
|
||||||
|
MaxSpareThreads 75
|
||||||
|
ThreadLimit 64
|
||||||
|
ThreadsPerChild 25
|
||||||
|
MaxRequestWorkers 150
|
||||||
|
MaxConnectionsPerChild 1000
|
||||||
|
</IfModule>
|
||||||
|
EOF \
|
||||||
|
&& a2enconf mpm-event-tuning \
|
||||||
|
\
|
||||||
|
# Logrotate
|
||||||
|
&& cat <<EOF > /etc/logrotate.d/apache2
|
||||||
|
/var/log/apache2/*.log {
|
||||||
|
weekly
|
||||||
|
missingok
|
||||||
|
rotate 4
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
notifempty
|
||||||
|
create 640 root adm
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
# Install PHP extensions
|
# PHP-FPM tuning
|
||||||
RUN set -ex; \
|
RUN sed -i 's/^pm = .*/pm = dynamic/' /etc/php/8.5/fpm/pool.d/www.conf && \
|
||||||
\
|
sed -i 's/^pm.max_children = .*/pm.max_children = 20/' /etc/php/8.5/fpm/pool.d/www.conf && \
|
||||||
savedAptMark="$(apt-mark showmanual)"; \
|
sed -i 's/^pm.start_servers = .*/pm.start_servers = 2/' /etc/php/8.5/fpm/pool.d/www.conf && \
|
||||||
\
|
sed -i 's/^pm.min_spare_servers = .*/pm.min_spare_servers = 2/' /etc/php/8.5/fpm/pool.d/www.conf && \
|
||||||
apt-get update && \
|
sed -i 's/^pm.max_spare_servers = .*/pm.max_spare_servers = 5/' /etc/php/8.5/fpm/pool.d/www.conf
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
libbz2-dev \
|
|
||||||
libgmp-dev \
|
|
||||||
libicu-dev \
|
|
||||||
libfreetype6-dev \
|
|
||||||
libjpeg-dev \
|
|
||||||
libldap2-dev \
|
|
||||||
libmemcached-dev \
|
|
||||||
libmagickwand-dev \
|
|
||||||
libpq-dev \
|
|
||||||
libpng-dev \
|
|
||||||
libwebp-dev \
|
|
||||||
libzip-dev \
|
|
||||||
; \
|
|
||||||
\
|
|
||||||
docker-php-ext-configure gd \
|
|
||||||
--with-freetype \
|
|
||||||
--with-jpeg \
|
|
||||||
--with-webp \
|
|
||||||
; \
|
|
||||||
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
|
|
||||||
docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \
|
|
||||||
docker-php-ext-configure intl; \
|
|
||||||
docker-php-ext-install -j "$(nproc)" \
|
|
||||||
bz2 \
|
|
||||||
bcmath \
|
|
||||||
exif \
|
|
||||||
gd \
|
|
||||||
gmp \
|
|
||||||
intl \
|
|
||||||
ldap \
|
|
||||||
mysqli \
|
|
||||||
pdo_mysql \
|
|
||||||
pdo_pgsql \
|
|
||||||
pgsql \
|
|
||||||
zip \
|
|
||||||
; \
|
|
||||||
pecl install imagick-3.6.0 && \
|
|
||||||
docker-php-ext-enable imagick && \
|
|
||||||
rm -r /tmp/pear; \
|
|
||||||
\
|
|
||||||
out="$(php -r 'exit(0);')"; \
|
|
||||||
[ -z "$out" ]; \
|
|
||||||
err="$(php -r 'exit(0);' 3>&1 1>&2 2>&3)"; \
|
|
||||||
[ -z "$err" ]; \
|
|
||||||
\
|
|
||||||
extDir="$(php -r 'echo ini_get("extension_dir");')"; \
|
|
||||||
[ -d "$extDir" ]; \
|
|
||||||
\
|
|
||||||
pecl install APCu-5.1.21 && \
|
|
||||||
pecl install memcached-3.2.0 && \
|
|
||||||
pecl install redis-5.3.7 && \
|
|
||||||
\
|
|
||||||
docker-php-ext-enable \
|
|
||||||
apcu \
|
|
||||||
memcached \
|
|
||||||
redis && \
|
|
||||||
rm -r /tmp/pear; \
|
|
||||||
\
|
|
||||||
apt-mark auto '.*' > /dev/null && \
|
|
||||||
apt-mark manual $savedAptMark && \
|
|
||||||
ldd "$extDir"/*.so | awk '/=>/ { print $3 }' | sort -u | xargs -r dpkg-query -S | cut -d: -f1 | sort -u | xargs -rt apt-mark manual; \
|
|
||||||
\
|
|
||||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
|
|
||||||
rm -rf /var/lib/apt/lists/* && \
|
|
||||||
! { ldd "$extDir"/*.so | grep 'not found'; } && \
|
|
||||||
err="$(php --version 3>&1 1>&2 2>&3)"; \
|
|
||||||
[ -z "$err" ]
|
|
||||||
|
|
||||||
# Set recommended PHP.ini settings
|
# PHP custom config
|
||||||
RUN set -eux; \
|
RUN mkdir -p /php && echo "PHP_INI_SCAN_DIR=/php" > /etc/environment
|
||||||
docker-php-ext-enable opcache; \
|
|
||||||
{ \
|
|
||||||
echo 'opcache.memory_consumption=128'; \
|
|
||||||
echo 'opcache.interned_strings_buffer=8'; \
|
|
||||||
echo 'opcache.max_accelerated_files=4000'; \
|
|
||||||
echo 'opcache.revalidate_freq=2'; \
|
|
||||||
echo 'opcache.fast_shutdown=1'; \
|
|
||||||
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
|
|
||||||
|
|
||||||
# Set recommended error logging
|
COPY php.ini /php/php.ini
|
||||||
RUN { \
|
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
|
||||||
echo 'error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR'; \
|
|
||||||
echo 'display_errors = Off'; \
|
|
||||||
echo 'display_startup_errors = Off'; \
|
|
||||||
echo 'log_errors = On'; \
|
|
||||||
echo 'error_log = /dev/stderr'; \
|
|
||||||
echo 'log_errors_max_len = 1024'; \
|
|
||||||
echo 'ignore_repeated_errors = On'; \
|
|
||||||
echo 'ignore_repeated_source = Off'; \
|
|
||||||
echo 'html_errors = Off'; \
|
|
||||||
} > /usr/local/etc/php/conf.d/error-logging.ini
|
|
||||||
|
|
||||||
# Enable Apache modules and configure RemoteIP
|
|
||||||
RUN set -eux; \
|
|
||||||
a2enmod expires headers rewrite remoteip socache_shmcb ssl && \
|
|
||||||
{ \
|
|
||||||
echo 'RemoteIPHeader X-Forwarded-For'; \
|
|
||||||
echo 'RemoteIPTrustedProxy 10.0.0.0/8'; \
|
|
||||||
echo 'RemoteIPTrustedProxy 172.16.0.0/12'; \
|
|
||||||
echo 'RemoteIPTrustedProxy 192.168.0.0/16'; \
|
|
||||||
echo 'RemoteIPTrustedProxy 169.254.0.0/16'; \
|
|
||||||
echo 'RemoteIPTrustedProxy 127.0.0.0/8'; \
|
|
||||||
} > /etc/apache2/conf-available/remoteip.conf; \
|
|
||||||
a2enconf remoteip; \
|
|
||||||
find /etc/apache2 -type f -name '*.conf' -exec sed -ri 's/([[:space:]]*LogFormat[[:space:]]+"[^"]*)%h([^"]*")/\1%a\2/g' '{}' +
|
|
||||||
|
|
||||||
# More Apache settings
|
|
||||||
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
|
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
CMD ["apache2-foreground"]
|
|
||||||
|
# Startup
|
||||||
|
COPY start.sh /start.sh
|
||||||
|
RUN chmod +x /start.sh
|
||||||
|
|
||||||
|
CMD ["/start.sh"]
|
||||||
53
README.md
53
README.md
@@ -1,8 +1,53 @@
|
|||||||
# 4 Lights Consulting
|

|
||||||
|
|
||||||
The apache php docker container that we use for production.
|
# CORXN - The Core Foundation of Novaconium
|
||||||
|
|
||||||
User Documentation: https://git.4lt.ca/4lt/phpcontainer/wiki
|
Links: [Dockerhub](https://hub.docker.com/r/4lights/corxn), [Git Repo](https://git.4lt.ca/4lt/CORXN)
|
||||||
|
|
||||||
Dockerhub: https://hub.docker.com/r/4lights/phpcontainer
|
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.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **PHP Version**: 8.5.3
|
||||||
|
- **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
|
||||||
|
```
|
||||||
|
## How to update image on dockerhub
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo su
|
||||||
|
docker buildx build --no-cache -t 4lights/corxn:8.5.3 -t 4lights/corxn:latest --load .
|
||||||
|
docker login -u <username>
|
||||||
|
docker push 4lights/corxn:8.5.3
|
||||||
|
docker push 4lights/corxn:latest
|
||||||
|
```
|
||||||
|
# Testing
|
||||||
|
|
||||||
|
Here is how to text the build:
|
||||||
|
```bash
|
||||||
|
mkdir -p data/uploads && sudo chown -R 33:33 data/uploads && chmod 775 data/uploads
|
||||||
|
docker compose up -d
|
||||||
|
# Visit: http://localhost:8000/test.php
|
||||||
|
# Test: file upload and that green checkmarks exist
|
||||||
|
```
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
|
||||||
|
```docker logs corxn```
|
||||||
|
|||||||
BIN
_assets/corxn-logo.png
Normal file
BIN
_assets/corxn-logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
39
docker-compose.yml
Normal file
39
docker-compose.yml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# Sample Docker Compose
|
||||||
|
services:
|
||||||
|
corxn:
|
||||||
|
image: 4lights/corxn:latest
|
||||||
|
ports:
|
||||||
|
- "8000:80"
|
||||||
|
volumes:
|
||||||
|
- ./test:/data # looks for /data/public
|
||||||
|
- ./php.ini:/php/php.ini:ro # Optional override php.ini
|
||||||
|
- ./data/uploads:/data/public/uploads
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- proxy
|
||||||
|
- internal
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:7
|
||||||
|
networks:
|
||||||
|
- internal
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
mariadb:
|
||||||
|
image: mariadb:11
|
||||||
|
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
|
||||||
5
docs/phpmyadmin.md
Normal file
5
docs/phpmyadmin.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# PHPMYADMIN
|
||||||
|
|
||||||
|
You may want to use PHPmyAdmin for testing.
|
||||||
|
|
||||||
|
Checkout [Docker Cookbooks](https://github.com/nickyeoman/docker-compose-cookbooks/blob/master/phpmyadmin/docker-compose.yml) for an example.
|
||||||
53
php.ini
Normal file
53
php.ini
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
[PHP]
|
||||||
|
; Performance
|
||||||
|
max_execution_time = 30
|
||||||
|
max_input_time = 60
|
||||||
|
memory_limit = 512M
|
||||||
|
|
||||||
|
; Uploads
|
||||||
|
upload_max_filesize = 100M
|
||||||
|
post_max_size = 100M
|
||||||
|
|
||||||
|
; Timezone
|
||||||
|
date.timezone = America/Vancouver
|
||||||
|
|
||||||
|
; Errors (production-safe)
|
||||||
|
display_errors = Off
|
||||||
|
display_startup_errors = Off
|
||||||
|
log_errors = On
|
||||||
|
error_log = /proc/self/fd/2
|
||||||
|
|
||||||
|
; Sessions
|
||||||
|
session.save_path = "/var/lib/php/sessions"
|
||||||
|
session.gc_maxlifetime = 1440
|
||||||
|
session.cookie_lifetime = 0
|
||||||
|
session.use_strict_mode = 1
|
||||||
|
|
||||||
|
; File handling
|
||||||
|
file_uploads = On
|
||||||
|
allow_url_fopen = On
|
||||||
|
|
||||||
|
; Realpath cache
|
||||||
|
realpath_cache_size = 4096k
|
||||||
|
realpath_cache_ttl = 120
|
||||||
|
|
||||||
|
; cURL
|
||||||
|
curl.cainfo = "/etc/ssl/certs/ca-certificates.crt"
|
||||||
|
|
||||||
|
; Mail (optional)
|
||||||
|
SMTP = localhost
|
||||||
|
sendmail_path = /usr/sbin/sendmail -t -i
|
||||||
|
|
||||||
|
; OPcache (IMPORTANT)
|
||||||
|
opcache.enable=1
|
||||||
|
opcache.enable_cli=1
|
||||||
|
opcache.memory_consumption=192
|
||||||
|
opcache.interned_strings_buffer=16
|
||||||
|
opcache.max_accelerated_files=20000
|
||||||
|
opcache.validate_timestamps=0
|
||||||
|
opcache.revalidate_freq=0
|
||||||
|
opcache.fast_shutdown=1
|
||||||
|
|
||||||
|
; Redis
|
||||||
|
session.save_handler = redis
|
||||||
|
session.save_path = "tcp://redis:6379"
|
||||||
6
start.sh
Normal file
6
start.sh
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
service php8.5-fpm start
|
||||||
|
|
||||||
|
exec apachectl -D FOREGROUND
|
||||||
151
test/public/test.php
Normal file
151
test/public/test.php
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
<!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/CORXN">Four Lights PHP Container: CORXN</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 = __DIR__ . '/uploads/';
|
||||||
|
|
||||||
|
$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>
|
||||||
Reference in New Issue
Block a user