Sign inSign up

chrno79/php-lftp

By chrno79

Updated 6 months ago

This Docker image provides an efficient web server with secure file synchronization via LFTP.

Image
Web servers
1

1.5K

chrno79/php-lftp repository overview

PHP-LFTP Docker Image (Optimized Trixie Builds)

This Docker image provides a efficient web server based on PHP 8.4 / 8.5 with Apache, designed to serve PHP applications while supporting secure file synchronization via lftp. It comes pre-configured with commonly used PHP extensions and allows PHP scripts to execute lftp commands via sudo for fetching files over FTP, FTPS, or SFTP.

✅ Features

Base Image: Built on the official PHP 8.4 / 8.5 Trixie image with Apache support, ensuring stability and compatibility for modern PHP applications.

Pre-installed PHP Extensions: Includes essential extensions for most web applications:

  • mysqli – MySQL database interactions
  • pdo, pdo_mysql – PDO support for MySQL
  • gd – Image processing and manipulation
  • mbstring – Multibyte string functions
  • curl – URL handling and data transfer
  • xml – XML parsing and manipulation
  • zip – Zip archive handling
  • opcache – Opcode caching for performance improvements
  • bcmath – Arbitrary precision mathematics
  • intl – Internationalization support
  • exif – Image metadata
  • sockets – Low-level socket support
  • pcntl – Process control for CLI scripts
  • redis – PECL extension for Redis support

File Synchronization with lftp:

  • PHP scripts running as www-data can securely execute lftp via sudo to synchronize files from remote servers using FTP, FTPS, or SFTP.

Apache Configuration:

  • mod_rewrite enabled for clean URLs and SEO-friendly routing
  • mod_remoteip pre-configured to handle the original client IP behind reverse proxies
  • Startup script auto-enables a mounted remoteip.conf, allowing trusted proxy IP ranges to be configured at runtime
  • Security headers configured: ServerTokens Prod, ServerSignature Off, TraceEnable Off

Production-ready PHP:

  • Opcache enabled and optimized
  • Memory and execution limits increased for large PHP applications
  • Session lifetime and upload limits configured

🚀 Getting Started

Pull the image from Docker Hub:

Run the PHP 8.4 container:

docker run -d --name webserver -p 80:80 chrno79/php-lftp:latest

Run the PHP 8.5 container:

docker run -d --name webserver -p 80:80 chrno79/php-lftp:dev

This will start Apache on port 80.


📁 Volume Mapping

To serve your PHP files:

docker run -d --name webserver -p 80:80 \
  -v /path/to/your/php/files:/var/www/html \
  chrno79/php-lftp:latest

Replace /path/to/your/php/files with the path to your PHP application.


🔧 Using RemoteIP

To forward the real client IP from a reverse proxy, mount your remoteip.conf:

RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 172.18.0.0/16   <-- Webspace Network
RemoteIPTrustedProxy 172.19.0.0/24   <-- Reverse Proxy Network

Mount it:

docker run -d --name webserver -p 80:80 \
  -v /path/to/remoteip.conf:/etc/apache2/conf-enabled/remoteip.conf:ro \
  -v /path/to/your/php/files:/var/www/html \
  chrno79/php-lftp:latest

The container automatically enables the config at startup.

Nginx-Proxy-Manager:

Edit Proxy Host -> Advanced -> Custom Nginx Configuration:

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;

🔧 Mount with custom php.ini:

You can provide your own PHP configuration:

docker run -d --name webserver -p 80:80 \
  -v /path/to/remoteip.conf:/etc/apache2/conf-enabled/remoteip.conf:ro \
  -v /path/to/your/php/files:/var/www/html \
  -v /path/to/your/custom_php.ini:/usr/local/etc/php/php.ini
  chrno79/php-lftp:latest

🤝 Contributing

Contributions are welcome! Fork the repository and submit pull requests for improvements, new features, or updated extensions.

Tag summary

Content type

Image

Digest

sha256:b5c2f795b

Size

398.3 MB

Last updated

7 months ago

docker pull chrno79/php-lftp