Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix: require patched PHP runtimes in WordPress templates

Juan Denisb85cc18220a1
diff --git a/backend/app/services/template_service.py b/backend/app/services/template_service.py
index c110db63..488725d3 100644
--- a/backend/app/services/template_service.py
+++ b/backend/app/services/template_service.py
@@ -1224,6 +1224,11 @@ class TemplateService(TemplateCatalogMixin, TemplateMagicMixin, TemplatePortsMix
created_files.append(filename)
+ # Relative files (e.g. Dockerfiles) are build inputs, not
+ # absolute container paths to mount into every service.
+ if not container_path.startswith('/'):
+ continue
+
# Track for bind mount: local file -> container path
# Get the container directory from the path
container_dir = os.path.dirname(container_path)
diff --git a/backend/templates/index.json b/backend/templates/index.json
index 1ad20774..7b522079 100644
--- a/backend/templates/index.json
+++ b/backend/templates/index.json
@@ -1088,7 +1088,7 @@
"id": "php-app",
"name": "PHP Application",
"version": "8.3",
- "description": "Custom PHP application with Apache. Supports PHP 8.0-8.3. Perfect for Laravel, WordPress themes, or any PHP project.",
+ "description": "Custom PHP application with Apache. Uses security-patched PHP 8.3. Perfect for Laravel, WordPress themes, or any PHP project.",
"icon": "https://serverkit.ai/imgs/template-icons/php-app.svg",
"categories": [
"development",
@@ -1628,7 +1628,7 @@
{
"id": "wordpress-external-db",
"name": "WordPress (External Database)",
- "version": "6.4",
+ "version": "7.1.3",
"description": "WordPress CMS connecting to an existing external MySQL database. Use this for dev/prod setups sharing the same database with different table prefixes.",
"icon": "https://serverkit.ai/imgs/template-icons/wordpress-external-db.png",
"categories": [
@@ -1641,7 +1641,7 @@
{
"id": "wordpress",
"name": "WordPress",
- "version": "6.4",
+ "version": "7.1.3",
"description": "World's most popular content management system for blogs and websites",
"icon": "https://serverkit.ai/imgs/template-icons/wordpress.png",
"categories": [
diff --git a/backend/templates/php-app.yaml b/backend/templates/php-app.yaml
index 580ba549..28b01720 100644
--- a/backend/templates/php-app.yaml
+++ b/backend/templates/php-app.yaml
@@ -1,7 +1,7 @@
id: php-app
name: PHP Application
version: "8.3"
-description: Custom PHP application with Apache. Supports PHP 8.0-8.3. Perfect for Laravel, WordPress themes, or any PHP project.
+description: Custom PHP application with Apache. Uses security-patched PHP 8.3. Perfect for Laravel, WordPress themes, or any PHP project.
icon: https://serverkit.ai/imgs/template-icons/php-app.svg
website: https://www.php.net
documentation: https://www.php.net/docs.php
@@ -17,9 +17,9 @@ variables:
default: "8100"
hidden: true
- name: PHP_VERSION
- description: PHP version (8.0, 8.1, 8.2, 8.3)
+ description: PHP version (minimum 8.3.36)
type: string
- default: "8.3"
+ default: "8.3.36"
ports:
- port: 8100
@@ -38,7 +38,7 @@ requirements:
compose:
services:
app:
- image: php:${PHP_VERSION:-8.3}-apache
+ image: php:${PHP_VERSION:-8.3.36}-apache
container_name: ${APP_NAME}
restart: unless-stopped
ports:
diff --git a/backend/templates/wordpress-external-db.yaml b/backend/templates/wordpress-external-db.yaml
index c1dc2c73..d8cbb2b1 100644
--- a/backend/templates/wordpress-external-db.yaml
+++ b/backend/templates/wordpress-external-db.yaml
@@ -1,6 +1,6 @@
id: wordpress-external-db
name: WordPress (External Database)
-version: "6.4"
+version: "7.1.3"
description: WordPress CMS connecting to an existing external MySQL database. Use this for dev/prod setups sharing the same database with different table prefixes.
icon: https://serverkit.ai/imgs/template-icons/wordpress-external-db.png
website: https://wordpress.org
@@ -13,9 +13,9 @@ categories:
variables:
- name: VERSION
- description: WordPress image tag (WP core + PHP variant, e.g. 6.4-php8.2-apache)
+ description: WordPress image tag (WP core + PHP variant, e.g. 7.1.3-php8.3-apache)
type: string
- default: "6.4-apache"
+ default: "7.1.3-php8.3-apache"
hidden: true
- name: HTTP_PORT
description: HTTP port for WordPress
@@ -66,7 +66,10 @@ requirements:
compose:
services:
wordpress:
- image: wordpress:${VERSION}
+ image: serverkit-wp-runtime:${APP_NAME}
+ build:
+ context: .
+ dockerfile: Dockerfile.serverkit-php
container_name: ${APP_NAME}
restart: unless-stopped
environment:
@@ -82,3 +85,13 @@ compose:
volumes:
wordpress_html:
+
+files:
+ - path: Dockerfile.serverkit-php
+ content: |
+ FROM wordpress:${VERSION}
+ RUN php -r '$v=PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION; $min=["8.2"=>"8.2.35","8.3"=>"8.3.36"]; exit(isset($min[$v]) && version_compare(PHP_VERSION,$min[$v],">=") ? 0 : 1);' \
+ && docker-php-ext-install pdo_mysql
+ RUN printf 'session.upload_progress.enabled=0\n' > /usr/local/etc/php/conf.d/zz-serverkit-security.ini \
+ && printf 'php_admin_flag session.upload_progress.enabled Off\n' > /etc/apache2/conf-available/serverkit-php-security.conf \
+ && a2enconf serverkit-php-security
diff --git a/backend/templates/wordpress.yaml b/backend/templates/wordpress.yaml
index da6d36e8..b749f598 100644
--- a/backend/templates/wordpress.yaml
+++ b/backend/templates/wordpress.yaml
@@ -1,6 +1,6 @@
id: wordpress
name: WordPress
-version: "6.4"
+version: "7.1.3"
description: World's most popular content management system for blogs and websites
icon: https://serverkit.ai/imgs/template-icons/wordpress.png
website: https://wordpress.org
@@ -12,9 +12,9 @@ categories:
variables:
- name: VERSION
- description: WordPress image tag (WP core + PHP variant, e.g. 6.4-php8.2-apache)
+ description: WordPress image tag (WP core + PHP variant, e.g. 7.1.3-php8.3-apache)
type: string
- default: "6.4-apache"
+ default: "7.1.3-php8.3-apache"
hidden: true
- name: HTTP_PORT
description: HTTP port
@@ -52,7 +52,10 @@ requirements:
compose:
services:
wordpress:
- image: wordpress:${VERSION}
+ image: serverkit-wp-runtime:${APP_NAME}
+ build:
+ context: .
+ dockerfile: Dockerfile.serverkit-php
container_name: ${APP_NAME}
restart: unless-stopped
environment:
@@ -88,3 +91,13 @@ compose:
volumes:
wordpress_html:
wordpress_db:
+
+files:
+ - path: Dockerfile.serverkit-php
+ content: |
+ FROM wordpress:${VERSION}
+ RUN php -r '$v=PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION; $min=["8.2"=>"8.2.35","8.3"=>"8.3.36"]; exit(isset($min[$v]) && version_compare(PHP_VERSION,$min[$v],">=") ? 0 : 1);' \
+ && docker-php-ext-install pdo_mysql
+ RUN printf 'session.upload_progress.enabled=0\n' > /usr/local/etc/php/conf.d/zz-serverkit-security.ini \
+ && printf 'php_admin_flag session.upload_progress.enabled Off\n' > /etc/apache2/conf-available/serverkit-php-security.conf \
+ && a2enconf serverkit-php-security
diff --git a/backend/tests/test_php_security_templates.py b/backend/tests/test_php_security_templates.py
new file mode 100644
index 00000000..09b93456
--- /dev/null
+++ b/backend/tests/test_php_security_templates.py
@@ -0,0 +1,23 @@
+from pathlib import Path
+
+import pytest
+import yaml
+
+from app.services.template_service import TemplateService
+
+
[email protected]('name', ['wordpress', 'wordpress-external-db'])
+def test_wordpress_build_files_do_not_become_container_mounts(tmp_path, name):
+ template = yaml.safe_load((Path(__file__).parents[1] / 'templates' / f'{name}.yaml').read_text())
+ variables = {'APP_NAME': 'test-wp', 'VERSION': '7.1.3-php8.3-apache'}
+ compose = tmp_path / 'docker-compose.yml'
+ compose.write_text(TemplateService.generate_compose(template, variables))
+ result = TemplateService._process_template_files(template['files'], str(tmp_path), str(compose), variables)
+ assert result['success']
+ config = yaml.safe_load(compose.read_text())
+ assert config['services']['wordpress']['volumes'] == ['wordpress_html:/var/www/html']
+ assert result['bind_mounts'] == 0
+ dockerfile = (tmp_path / 'Dockerfile.serverkit-php').read_text()
+ assert 'FROM wordpress:7.1.3-php8.3-apache' in dockerfile
+ assert '8.3.36' in dockerfile and 'pdo_mysql' in dockerfile
+ assert 'php_admin_flag session.upload_progress.enabled Off' in dockerfile