commit 7b4a66d8bdec846f0fe86e3676934af1ea356865
parent 8ae1cc4426e00c3779eed993f03ae518104511ec
Author: MTRNord <MTRNord@users.noreply.github.com>
Date: Thu, 16 Oct 2025 15:27:27 +0200
fixes?
Signed-off-by: MTRNord <MTRNord@users.noreply.github.com>
Diffstat:
8 files changed, 272 insertions(+), 44 deletions(-)
diff --git a/apps/talos_cluster/blog/docker/10-opcache.ini b/apps/talos_cluster/blog/docker/10-opcache.ini
@@ -7,7 +7,12 @@ opcache.jit=tracing
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
-opcache.interned_strings_buffer=12
+opcache.interned_strings_buffer=16
;opcache.max_accelerated_files=4000
;opcache.revalidate_freq=2
-opcache.max_wasted_percentage=5
+opcache.validate_timestamps=0
+opcache.max_accelerated_files=10000
+opcache.fast_shutdown=1
+; Experimental
+opcache.preload=/var/www/html/wordpress/opcache-preload.php
+opcache.preload_user=www-data
diff --git a/apps/talos_cluster/blog/docker/Dockerfile b/apps/talos_cluster/blog/docker/Dockerfile
@@ -56,10 +56,72 @@ COPY php.ini /etc/php/8.4/fpm/php.ini
RUN wget -q https://wordpress.org/latest.zip \
&& unzip -q latest.zip -d /var/www/html/ \
&& rm latest.zip
+# Install WP Super Cache plugin
+RUN wget -q https://downloads.wordpress.org/plugin/wp-super-cache.3.0.2.zip \
+ && unzip -q wp-super-cache.3.0.2.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm wp-super-cache.3.0.2.zip
+# Install Redis Object Cache plugin
+RUN wget -q https://downloads.wordpress.org/plugin/redis-cache.2.7.0.zip \
+ && unzip -q redis-cache.2.7.0.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm redis-cache.2.7.0.zip
+# Install ActivityPub plugin
+RUN wget -q https://downloads.wordpress.org/plugin/activitypub.7.5.0.zip \
+ && unzip -q activitypub.7.5.0.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm activitypub.7.5.0.zip
+# Install Embed Optimizer
+RUN wget -q https://downloads.wordpress.org/plugin/embed-optimizer.1.0.0-beta2.zip \
+ && unzip -q embed-optimizer.1.0.0-beta2.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm embed-optimizer.1.0.0-beta2.zip
+# Install Enhanced Responsive Images
+RUN wget -q https://downloads.wordpress.org/plugin/auto-sizes.1.7.0.zip \
+ && unzip -q auto-sizes.1.7.0.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm auto-sizes.1.7.0.zip
+# Install Friends
+RUN wget -q https://downloads.wordpress.org/plugin/friends.3.6.0.zip \
+ && unzip -q friends.3.6.0.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm friends.3.6.0.zip
+# Install Image Placeholders
+RUN wget -q https://downloads.wordpress.org/plugin/dominant-color-images.1.2.0.zip \
+ && unzip -q dominant-color-images.1.2.0.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm dominant-color-images.1.2.0.zip
+# Install Image Prioritizer
+RUN wget -q https://downloads.wordpress.org/plugin/image-prioritizer.1.0.0-beta2.zip \
+ && unzip -q image-prioritizer.1.0.0-beta2.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm image-prioritizer.1.0.0-beta2.zip
+# Install Index WP MySQL For Speed
+RUN wget -q https://downloads.wordpress.org/plugin/index-wp-mysql-for-speed.1.5.4.zip \
+ && unzip -q index-wp-mysql-for-speed.1.5.4.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm index-wp-mysql-for-speed.1.5.4.zip
+# Install Modern Image Formats
+RUN wget -q https://downloads.wordpress.org/plugin/webp-uploads.2.6.0.zip \
+ && unzip -q webp-uploads.2.6.0.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm webp-uploads.2.6.0.zip
+# Install Optimization Detective
+RUN wget -q https://downloads.wordpress.org/plugin/optimization-detective.1.0.0-beta3.zip \
+ && unzip -q optimization-detective.1.0.0-beta3.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm optimization-detective.1.0.0-beta3.zip
+# Install Performance Lab
+RUN wget -q https://downloads.wordpress.org/plugin/performance-lab.4.0.0.zip \
+ && unzip -q performance-lab.4.0.0.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm performance-lab.4.0.0.zip
+# Install Speculative Loading
+RUN wget -q https://downloads.wordpress.org/plugin/speculation-rules.1.6.0.zip \
+ && unzip -q speculation-rules.1.6.0.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm speculation-rules.1.6.0.zip
+# Install WP Mail SMTP
+RUN wget -q https://downloads.wordpress.org/plugin/wp-mail-smtp.4.6.0.zip \
+ && unzip -q wp-mail-smtp.4.6.0.zip -d /var/www/html/wordpress/wp-content/plugins/ \
+ && rm wp-mail-smtp.4.6.0.zip
+
+# Install twenty-twenty-five theme
+RUN wget -q https://downloads.wordpress.org/theme/twentytwentyfive.1.3.zip \
+ && unzip -q -o twentytwentyfive.1.3.zip -d /var/www/html/wordpress/wp-content/themes/ \
+ && rm twentytwentyfive.1.3.zip
# Configure nginx: replace default site and enable wordpress config
RUN rm -f /etc/nginx/sites-enabled/default
COPY wordpress.conf /etc/nginx/sites-available/wordpress.conf
+COPY nginx.conf /etc/nginx/nginx.conf
RUN ln -s /etc/nginx/sites-available/wordpress.conf /etc/nginx/sites-enabled/wordpress.conf
# Copy redis config and well-known files
@@ -75,6 +137,7 @@ COPY wp-config.php /var/www/html/wordpress/wp-config.php
COPY advanced-cache.php /var/www/html/wordpress/wp-content/advanced-cache.php
COPY wp-cache-config.php /var/www/html/wordpress/wp-content/wp-cache-config.php
COPY object-cache.php /var/www/html/wordpress/wp-content/object-cache.php
+COPY opcache-preload.php /var/www/html/wordpress/opcache-preload.php
# Fix permissions for the webroot
RUN chown -R www-data:www-data /var/www/ \
diff --git a/apps/talos_cluster/blog/docker/nginx.conf b/apps/talos_cluster/blog/docker/nginx.conf
@@ -0,0 +1,105 @@
+user www-data;
+worker_processes auto;
+worker_cpu_affinity auto;
+pid /run/nginx.pid;
+worker_rlimit_nofile 100000;
+error_log stderr;
+include /etc/nginx/modules-enabled/*.conf;
+
+events {
+ worker_connections 4000;
+ use epoll;
+ multi_accept on;
+}
+
+http {
+ # cache informations about FDs, frequently accessed files
+ # can boost performance, but you need to test those values
+ open_file_cache max=200000 inactive=20s;
+ open_file_cache_valid 30s;
+ open_file_cache_min_uses 2;
+ open_file_cache_errors on;
+
+ fastcgi_buffering off;
+ proxy_buffering off;
+ fastcgi_keep_conn on;
+ fastcgi_max_temp_file_size 0;
+
+
+ ##
+ # Basic Settings
+ ##
+
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+ types_hash_max_size 2048;
+ server_tokens off; # Recommended practice is to turn this off
+
+ reset_timedout_connection on;
+ client_body_timeout 60;
+ send_timeout 5;
+ keepalive_timeout 30;
+
+ # server_names_hash_bucket_size 64;
+ # server_name_in_redirect off;
+
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ ##
+ # SSL Settings
+ ##
+
+ ssl_protocols TLSv1.2 TLSv1.3; # Dropping SSLv3 (POODLE), TLS 1.0, 1.1
+ ssl_prefer_server_ciphers off; # Don't force server cipher order.
+
+ ##
+ # Logging Settings
+ ##
+
+ access_log stdout;
+
+ ##
+ # Gzip Settings
+ ##
+
+ gzip on;
+
+ gzip_vary on;
+ gzip_proxied any;
+ gzip_comp_level 6;
+ gzip_buffers 16 8k;
+ gzip_http_version 1.1;
+ gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
+
+
+ ##
+ # Virtual Host Configs
+ ##
+
+ include /etc/nginx/conf.d/*.conf;
+ include /etc/nginx/sites-enabled/*;
+}
+
+
+#mail {
+# # See sample authentication script at:
+# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
+#
+# # auth_http localhost/auth.php;
+# # pop3_capabilities "TOP" "USER";
+# # imap_capabilities "IMAP4rev1" "UIDPLUS";
+#
+# server {
+# listen localhost:110;
+# protocol pop3;
+# proxy on;
+# }
+#
+# server {
+# listen localhost:143;
+# protocol imap;
+# proxy on;
+# }
+#}
diff --git a/apps/talos_cluster/blog/docker/opcache-preload.php b/apps/talos_cluster/blog/docker/opcache-preload.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * WordPress opcache preloading.
+ * Requires PHP >= 7.4.
+ *
+ * @author Konrad Fedorczyk <contact@realhe.ro>
+ * @link https://stitcher.io/blog/preloading-in-php-74
+ *
+ * @version 1.0.0
+ */
+
+/**
+ * Uwaga! Adjust your path.
+ */
+define('APP_PATH', '/var/www/html/wordpress/');
+
+$preload_patterns = [
+ // WP native files (priority).
+ 'wp-load.php',
+ 'wp-includes/http.php',
+ 'wp-includes/class-http.php',
+ //'wp-includes/general-template.php',
+ //'wp-includes/link-template.php',
+ 'wp-includes/class-wp-http-response.php',
+ 'wp-includes/class-wp-http-requests-hooks.php',
+ 'wp-includes/class-wp-http-proxy.php',
+ 'wp-includes/class-wp-http-requests-response.php',
+ 'wp-includes/class-wp-http-cookie.php',
+ 'wp-includes/class-wp-query.php',
+ 'wp-includes/class-wp-tax-query.php',
+ 'wp-includes/class-wp-user.php',
+ 'wp-includes/class-wp-post.php',
+ 'wp-includes/class-wp-roles.php',
+ 'wp-includes/class-wp-role.php',
+
+ 'wp-includes/taxonomy.php',
+ 'wp-includes/post.php',
+ 'wp-includes/user.php',
+ 'wp-includes/pluggable.php',
+ 'wp-includes/rest-api.php',
+ 'wp-includes/kses.php',
+ 'wp-includes/capabilities.php',
+ 'wp-includes/comment.php',
+ 'wp-includes/query.php',
+ //'wp-includes/l10n.php',
+ 'wp-includes/shortcodes.php',
+ 'wp-includes/theme.php',
+ 'wp-includes/post-template.php',
+ 'wp-includes/post-thumbnail-template.php',
+ 'wp-includes/media.php',
+ 'wp-includes/date.php',
+ 'wp-includes/author-template.php',
+
+ // Rest WP files.
+ "wp-includes/**/*.php",
+ "wp-includes/**/**/*.php",
+ "wp-includes/**/**/**/*.php",
+ "wp-includes/**/**/**/**/*.php",
+];
+
+foreach ($preload_patterns as $pattern) {
+ $files = glob(APP_PATH . $pattern);
+
+ foreach ($files as $file) {
+ opcache_compile_file($file);
+ }
+}
diff --git a/apps/talos_cluster/blog/docker/php.ini b/apps/talos_cluster/blog/docker/php.ini
@@ -1,7 +1,6 @@
[PHP]
engine = On
short_open_tag = Off
-asp_tags = Off
precision = 14
@@ -12,7 +11,7 @@ zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
-serialize_precision = 17
+serialize_precision = "-1"
disable_functions =
@@ -22,7 +21,7 @@ zend.enable_gc = On
expose_php = On
-max_execution_time = 350
+max_execution_time = 60
memory_limit = 256M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
@@ -50,8 +49,6 @@ auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
-always_populate_raw_post_data = -1
-
cgi.discard_path = 1
cgi.fix_pathinfo = 0
@@ -70,10 +67,6 @@ cli_server.color = On
[Date]
date.timezone = Europe/Berlin
-[Pdo_mysql]
-pdo_mysql.cache_size = 2000
-pdo_mysql.default_socket =
-
[ODBC]
;odbc.default_db = Not yet implemented
@@ -103,14 +96,8 @@ ibase.timeformat = "%H:%M:%S"
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
-mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
-mysql.default_port =
-mysql.default_socket =
-mysql.default_host =
-mysql.default_user =
-mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
@@ -119,7 +106,6 @@ mysql.trace_mode = Off
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
-mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
@@ -138,7 +124,7 @@ mysqlnd.collect_memory_statistics = Off
bcmath.scale = 0
[Session]
-url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
+url_rewriter.tags = "form="
session.save_handler = files
;session.save_path = "/tmp"
@@ -151,7 +137,7 @@ session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
-session.cookie_httponly =
+session.cookie_httponly = "0"
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
@@ -163,7 +149,6 @@ session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
-session.hash_bits_per_character = 5
;session.upload_progress.enabled = On
;session.upload_progress.cleanup = On
;session.upload_progress.prefix = "upload_progress_"
diff --git a/apps/talos_cluster/blog/docker/wordpress.conf b/apps/talos_cluster/blog/docker/wordpress.conf
@@ -8,6 +8,7 @@ upstream phpfpm {
keepalive 32;
# fallback to TCP socket if needed (uncomment and configure host:port)
# server 127.0.0.1:9000;
+ ip_hash;
}
server {
@@ -19,15 +20,6 @@ server {
error_log stderr;
set $cache_uri $request_uri;
- gzip on;
-
- gzip_vary on;
- gzip_proxied any;
- gzip_comp_level 6;
- gzip_buffers 16 8k;
- gzip_http_version 1.1;
- gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
-
server_name _;
# Allow access to /.well-known/matrix before dotfile deny rule
@@ -67,8 +59,9 @@ server {
include fastcgi.conf;
fastcgi_intercept_errors on;
- fastcgi_read_timeout 300s;
- proxy_read_timeout 300s;
+ fastcgi_read_timeout 60s;
+ proxy_read_timeout 60s;
+ fastcgi_keep_conn on;
fastcgi_pass phpfpm;
}
@@ -119,8 +112,9 @@ server {
include fastcgi.conf;
fastcgi_intercept_errors on;
- fastcgi_read_timeout 300s;
- proxy_read_timeout 300s;
+ fastcgi_read_timeout 60s;
+ proxy_read_timeout 60s;
+ fastcgi_keep_conn on;
fastcgi_pass phpfpm;
}
diff --git a/apps/talos_cluster/blog/docker/www.conf b/apps/talos_cluster/blog/docker/www.conf
@@ -113,7 +113,7 @@ listen.group = www-data
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
-pm = ondemand
+pm = dynamic
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
@@ -124,12 +124,12 @@ pm = ondemand
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
-pm.max_children = 50
+pm.max_children = 10
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: (min_spare_servers + max_spare_servers) / 2
-pm.start_servers = 5
+pm.start_servers = 4
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
@@ -139,7 +139,7 @@ pm.min_spare_servers = 2
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
-pm.max_spare_servers = 10
+pm.max_spare_servers = 6
; The number of rate to spawn child processes at once.
; Note: Used only when pm is set to 'dynamic'
@@ -493,3 +493,12 @@ php_admin_value[output_buffering] = 0
php_admin_value[max_input_time] = 3600
php_admin_value[max_input_nesting_level] = 256
php_admin_value[max_input_vars] = 10000
+
+; Opcache
+php_admin_value[opcache.enable]=1
+php_admin_value[opcache.memory_consumption]=256
+php_admin_value[opcache.interned_strings_buffer]=16
+php_admin_value[opcache.max_accelerated_files]=10000
+php_admin_value[opcache.validate_timestamps]=0
+php_admin_value[realpath_cache_size]=4096K
+php_admin_value[realpath_cache_ttl]=600
diff --git a/apps/talos_cluster/blog/wordpress.yaml b/apps/talos_cluster/blog/wordpress.yaml
@@ -103,12 +103,12 @@ spec:
- name: wordpress-persistent-storage
mountPath: /var/www/html/wordpress/wp-content/uploads
subPath: uploads
- - name: wordpress-persistent-storage
- mountPath: /var/www/html/wordpress/wp-content/plugins
- subPath: plugins
- - name: wordpress-persistent-storage
- mountPath: /var/www/html/wordpress/wp-content/themes
- subPath: themes
+ #- name: wordpress-persistent-storage
+ # mountPath: /var/www/html/wordpress/wp-content/plugins
+ # subPath: plugins
+ #- name: wordpress-persistent-storage
+ # mountPath: /var/www/html/wordpress/wp-content/themes
+ # subPath: themes
readinessProbe:
httpGet:
path: /wp-login.php