| Conception Logicielle | Développement logiciel | Réalisation de projet |
| Examen d'application | Architecture de code | Accompagnement à l'utilisation |
| Conception Logicielle | Développement logiciel | Réalisation de projet |
| Examen d'application | Architecture de code | Accompagnement à l'utilisation |
In this technique, the version of the php-fpm package is selected according to the version indicated in dnf, to see it: dnf module list php
I use a php-fpm.conf configuration for nginx that points to the php-fpm package socket, so I can keep the upstream up to date when I change the php version using this method.
nginx/conf.d/php-fpm.conf
# PHP-FPM FastCGI server
# network or unix domain socket configuration
upstream php-fpm {
unix server:/run/php-fpm/www.sock;
}
Please note that reinstalling php-fpm means reinitializing /etc/php-fpm.d/www.conf, which means that a custom configuration will be overwritten.
This is how I proceed:
I add my custom configuration in a 60-custom-after.conf file so that it overrides 50-default.conf
When I reinstall php-fpm, a file /etc/php-fpm.d/www.conf is recreated:
For over a decade, the combination of Nginx and PHP-FPM has been the industry standard for hosting demanding PHP applications like Magento 2. In that traditional model, Nginx acts as a reverse proxy that forwards HTTP requests to an isolated pool of PHP-FPM workers. While highly robust, this traditional lifecycle is strictly stateless: for every single request, the environment boots up, executes the script, and tears down. This introduces inter-process communication (IPC) overhead and constant filesystem I/O.
FrankenPHP introduces a fundamental paradigm shift that aligns PHP with modern runtimes like Node.js or Go. In a Node.js ecosystem, the application server is persistent; it stays alive in memory, listens to ports natively, and handles incoming requests instantly without re-initializing the application framework. By embedding the PHP interpreter directly into the Go-based Caddy web server via Zend Thread Safety (ZTS), FrankenPHP allows PHP to adopt this exact worker model. The application stays resident in memory, eliminating Unix/TCP socket overhead, delivering native HTTP/3 out of the box, and unlocking immense performance gains while retaining full compatibility with complex monoliths like Magento 2.
The objective of this specific implementation is to seamlessly integrate FrankenPHP with a Magento 2 (v2.4.9) project deployed in the standard Linux web directory (/var/www/html/magento2), while adhering to two major constraints:
/var/www/ path for the web root, combined with a minimal Systemd override (ProtectHome=false) to ensure FrankenPHP can interact smoothly with any local user environment assets without breaking core system security rules.Sign Static Files) without tampering with the core application.Routing Flow Mechanics:
When a browser requests a static asset that hasn't been generated yet (e.g., calendar.css):
1. Browser ➡️ Sends request with a version token (/static/versionXXXX/css...) ➡️ Caddy/FrankenPHP.
2. Caddy detects the absence of the physical file ➡️ It performs a surgical rewrite of the resource argument (removing the version token) BUT preserves the original raw URI containing the version inside $_SERVER['REQUEST_URI'].
3. Magento (static.php) validates the security signature via the raw URI, reads the cleaned resource argument, and creates the native symlink from pub/static/ to vendor/.
4. Subsequent requests hit the actual symlink ➡️ Caddy serves it instantly in HTTP/3 via its file_server without ever hitting PHP again.
FrankenPHP relies on a worker architecture powered by threads. It strictly requires PHP extensions compiled with ZTS (Zend Thread Safety). To avoid port conflicts on 80 and 443, any legacy web server (Nginx) and PHP processor (PHP-FPM) must be stopped and disabled. We then leverage the recommended Native RPM Repository method to install FrankenPHP and its ZTS 8.5 dependencies dynamically linked with Remi's repository.
Stop and disable legacy engines to free ports 80/443 and prevent socket overlaps:
Add the official RPM repository providing production-ready FrankenPHP builds for Enterprise Linux:
Reset the standard single-threaded DNF PHP module to allow a custom repository override:
Switch to Remi's PHP 8.5 repository to align our runtime with Magento 2.4.9 prerequisites:
Install FrankenPHP alongside PHP-ZTS. Why PHP-ZTS? Because FrankenPHP embeds PHP directly into its Go-based server. Standard PHP is non-thread-safe (NTS) and crashes under simultaneous multi-threaded requests; ZTS (Zend Thread Safety) isolates memory per thread, enabling safe, high-performance concurrent request processing:
To establish a secure bridge between your local development user (PK) and the webserver, FrankenPHP requires execution rights (traverse permission) on the user's home directory. Two strategies can be deployed depending on the desired granularity:
Option A: Standard Group Strategy (Used in this setup)
FrankenPHP is added to the user's private group, and the home directory's permission is widened to 710. This grants FrankenPHP the exact execution right needed to traverse the home directory structure (--x) while blocking any other unprivileged system users.
Option B: Advanced ACL Strategy (Granular Alternative)
If you prefer to keep your home directory strictly private (700) without altering standard POSIX groups, you can use Linux Access Control Lists (ACLs). This explicitly targets the frankenphp user alone, granting it traverse rights without exposing the folder to a whole group.
Regardless of the chosen home directory traversal method, the /var/www/html/ deployment path must be configured with full group ownership and proper write access to handle Magento's dynamic code compilation and asset generation processes seamlessly:
On Enterprise Linux 9 systems, SELinux enforcement will immediately block FrankenPHP from serving files or executing scripts if the security contexts do not match. We must apply the correct httpd_sys_content_t context for read-only areas and httpd_sys_rw_content_t for areas where Magento needs to write or generate Symlinks at runtime.
Additionally, we must authorize the webserver process to communicate with the network (e.g., Database connections, Elasticsearch/OpenSearch, and Redis instances):
To guarantee that FrankenPHP can resolve user-level operations, handle CLI tasks seamlessly, and access any required local environment configurations, the native home directory protection must be disabled.
Inside the override file, inject the following minimal configuration:
[Service]
ProtectHome=false
To ensure a clean, maintainable infrastructure, the main Caddyfile handles global directives and dynamically includes sub-configurations. Magento 2 routing logic is isolated inside its own file.
Main File: /etc/frankenphp/Caddyfile
{
# Global Configuration
frankenphp
order php_server before file_server
}
# Include all modular site configurations
import /etc/frankenphp/Caddyfile.d/*.caddyfile
Sub-File: /etc/frankenphp/Caddyfile.d/magento2.caddyfile
magento2.localhost.com {
# Document root strictly pointing to Magento's pub/ folder
root * /var/www/html/magento2/pub
tls internal
encode zstd gzip
header {
X-Content-Type-Options "nosniff"
X-XSS-Protection "1; mode=block"
X-Frame-Options "SAMEORIGIN"
}
# 1. Handle missing versioned static assets (Sign Static Files active)
@static_versioned_missing {
path_regexp versioned ^/static/version\d+/(.+)
not file {path}
}
rewrite @static_versioned_missing /static.php?resource={re.versioned.1}
# 2. Handle missing unversioned static assets
@static_normal_missing {
path /static/*
not path_regexp ^/static/version\d+/
not file {path}
}
rewrite @static_normal_missing /static.php?resource={bits.path.strip_prefix./static/}
# 3. Handle missing media (On-the-fly catalog image resizing)
@media_missing {
path /media/*
not file {path}
}
rewrite @media_missing /get.php?resource={path}
# 4. Global application fallback router (HTML pages and root /)
@magento_fallback {
not file {path}
not path /static/* /media/*
}
rewrite @magento_fallback /index.php?{query}
# 5. Execution Engines
file_server
php_server
}
To enable the RPM-managed service, apply the new architecture, and completely flush any previous 403/404 errors cached by the system or application:
The core application runs flawlessly, database interactions are up, SELinux enforcement policies are respected, signatures match perfectly, and the Luma theme renders instantly via native Linux symlinks!
Le site pascalkoch.net est édité par Monsieur Pascal Koch
Tél: (+33)6 28 07 14 16
Courriel: applicatif@pascalkoch.net
DIRECTEUR DE LA PUBLICATION
Le directeur de la publication du site pascalkoch.net est Monsieur Pascal Koch
Le responsable éditorial du site pascalkoch.net est Monsieur Pascal Koch
HEBERGEUR
Le site pascalkoch.net est hébergé par la société Namecheap Inc. (“Namecheap.com”) ICANN accredited domain name registrar and web hosting company , dont le siège social est 11400 W. Olympic Blvd., Suite 200
Los Angeles, CA 90064 USA .
Tél : 323-448-0232
Courriel : support@namecheap.com.
PROPRIETE INTELLECTUELLE
La structure générale du site pascalkoch.net, ainsi que les textes, graphiques, images, sons et vidéos la composant, sont la propriété de Monsieur Pascal Koch ou de ses partenaires. Toute représentation et/ou reproduction et/ou exploitation partielle ou totale de ce site, par quelque procédé que ce soit, sans l'autorisation préalable et par écrit de Monsieur Pascal Koch ou de ses partenaires est strictement interdite et serait susceptible de constituer une contrefaçon au sens des articles L 335-2 et suivants du Code de la propriété intellectuelle.
LOI INFORMATIQUE ET LIBERTES
Conformément à la loi Informatique et Liberté 78-17 du 6 janvier 1978 modifiée, vous disposez d'un droit d'opposition (art. 38), d'accès (art. 39), de rectification ou de suppression (art. 40) des données qui vous concernent. Vous pouvez exercer ce droit en vous adressant à Monsieur Pascal Koch
Ce droit s'exerce, en justifiant de son identité :
par voie postale : 389 rue de la République 69430 Beaujeu
par courrier électronique : applicatif@pascalkoch.net
Toutes les données personnelles qui sont recueillies sont traitées avec la plus stricte confidentialité. En particulier, Monsieur Pascal Koch s’engage à respecter la confidentialité des messages courriels transmis au moyen d’une messagerie électronique.
Le site utilise également des cookies bloqués jusqu'au consentement explicite selon la directive 2002/58/CE du Parlement européen et du Conseil du 12 juillet 2002.
Encore une fois aucune donnée à caractère personnelle ne sera collectée.
MÉDIATION (en présence d'un client-consommateur)
En application du nouvel article R. 156-1 du code de la consommation, le professionnel devra communiquer au consommateur les coordonnées du ou des médiateurs de la consommation dont il relève, en inscrivant ces informations de manière visible et lisible sur son site internet, sur ses conditions générales de l'ente ou du service, sur ses bons de commande ou sur tout autre support adapté. Il mentionnera également l'adresse du site interne du ou des médiateurs. Tout manquement à ces dispositions est passible d'une amende administrative dont le montant peut atteindre 3000 € pour une personne physique et 15000 € pour une personne morale (art. L. 156-1 et s. C.c onsom).
LE CLIENT, s'il le souhaite, peut saisir le médiateur de la consommation des communications électroniques:
Le médiateur des communications électroniques
CS 30342
94257 Gentilly cedex
Site Internet : http://www.mediateur-telecom.fr/
Cet élément sera supprimé de manière permanente et ne pourra être restauré. Êtes-vous sur(e)?