{"id":659,"date":"2026-09-06T12:12:43","date_gmt":"2026-09-06T15:12:43","guid":{"rendered":"https:\/\/www.linuxpro.com.br\/2026\/09\/nginx-varias-versoes-php-debian-ubuntu\/"},"modified":"2026-09-08T12:00:17","modified_gmt":"2026-09-08T15:00:17","slug":"nginx-varias-versoes-php-debian-ubuntu","status":"publish","type":"post","link":"https:\/\/www.linuxpro.com.br\/en\/2026\/09\/nginx-varias-versoes-php-debian-ubuntu\/","title":{"rendered":"Nginx and multiple PHP versions on Debian and Ubuntu"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" alt=\"Mascote do LinuxPro ligando o nginx a tr\u00eas PHP-FPM, placa 3D do hex\u00e1gono verde na parede\" src=\"\/wp-content\/uploads\/2026\/09\/nginx-multi-php-v4.webp\" width=\"1486\" height=\"856\" \/><\/p>\n<p>Debian 12 traz PHP 8.2. Ubuntu 24.04, 8.3. Debian 13, 8.4. Ubuntu 26.04, 8.5. Um host de verdade precisa dos tr\u00eas ao mesmo tempo: o WordPress antigo, o Laravel novo, o CLI do cron. O repo da distro n\u00e3o deixa. O de <a href=\"https:\/\/packages.sury.org\/php\/\">Ond\u0159ej Sur\u00fd<\/a> deixa. O nginx sai do <a href=\"https:\/\/nginx.org\/en\/linux_packages.html\">nginx.org<\/a> \u2014 est\u00e1vel, pinado, sem misturar m\u00f3dulo da distro.<\/p>\n<p><!-- more --><\/p>\n<h2>O mapa em setembro de 2026<\/h2>\n<p>PHP no <a href=\"https:\/\/www.php.net\/supported-versions.php\">ciclo oficial<\/a>:<\/p>\n<ul>\n<li><strong>8.5<\/strong> \u2014 ativo at\u00e9 dez\/2027, seguran\u00e7a at\u00e9 dez\/2029 (saiu 20 nov 2025)<\/li>\n<li><strong>8.4<\/strong> \u2014 ativo at\u00e9 dez\/2026, seguran\u00e7a at\u00e9 dez\/2028<\/li>\n<li><strong>8.3<\/strong> \u2014 s\u00f3 seguran\u00e7a, at\u00e9 dez\/2027<\/li>\n<li><strong>8.2<\/strong> \u2014 seguran\u00e7a at\u00e9 <strong>31 dez 2026<\/strong><\/li>\n<li>8.1 morreu em 31 dez 2025 \u2014 n\u00e3o instale em caixa nova<\/li>\n<\/ul>\n<p>Sury coinstala <code>php8.3-fpm<\/code>, <code>php8.4-fpm<\/code> e <code>php8.5-fpm<\/code> no mesmo box. Cada um tem socket pr\u00f3prio em <code>\/run\/php\/<\/code>. O nginx escolhe o socket no vhost.<\/p>\n<p>O repo de nginx do Sury <strong>fechou em abril de 2026<\/strong>. PHP continua em <code>packages.sury.org\/php<\/code>. Nginx: distro <em>ou<\/em> nginx.org. N\u00e3o misture os dois bin\u00e1rios.<\/p>\n<h2>Nginx pelo nginx.org<\/h2>\n<p>Debian 12 (bookworm), 13 (trixie); Ubuntu 24.04 (noble), 26.04 (resolute). amd64 e arm64. Fingerprint da chave: <code>573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62<\/code> (expira 24 mai 2027).<\/p>\n<p>Debian:<\/p>\n<pre><code class=\"language-bash\">sudo apt install -y curl gnupg2 ca-certificates lsb-release debian-archive-keyring\ncurl https:\/\/nginx.org\/keys\/nginx_signing.key | gpg --dearmor \n  | sudo tee \/usr\/share\/keyrings\/nginx-archive-keyring.gpg &gt;\/dev\/null\ngpg --dry-run --quiet --no-keyring --import --import-options import-show \n  \/usr\/share\/keyrings\/nginx-archive-keyring.gpg\necho \"deb [signed-by=\/usr\/share\/keyrings\/nginx-archive-keyring.gpg] \nhttps:\/\/nginx.org\/packages\/debian $(lsb_release -cs) nginx\" \n  | sudo tee \/etc\/apt\/sources.list.d\/nginx.list\n<\/code><\/pre>\n<p>Ubuntu \u2014 s\u00f3 muda o keyring e a URL:<\/p>\n<pre><code class=\"language-bash\">sudo apt install -y curl gnupg2 ca-certificates lsb-release ubuntu-keyring\ncurl https:\/\/nginx.org\/keys\/nginx_signing.key | gpg --dearmor \n  | sudo tee \/usr\/share\/keyrings\/nginx-archive-keyring.gpg &gt;\/dev\/null\necho \"deb [signed-by=\/usr\/share\/keyrings\/nginx-archive-keyring.gpg] \nhttps:\/\/nginx.org\/packages\/ubuntu $(lsb_release -cs) nginx\" \n  | sudo tee \/etc\/apt\/sources.list.d\/nginx.list\n<\/code><\/pre>\n<p>Pin para o apt n\u00e3o voltar ao nginx da distro, e instale o est\u00e1vel (n\u00famero par: 1.30.x em 2026). Mainline \u00e9 <code>...\/mainline\/debian<\/code> ou <code>...\/mainline\/ubuntu<\/code>.<\/p>\n<pre><code class=\"language-bash\">printf '%sn' 'Package: *' 'Pin: origin nginx.org' 'Pin: release o=nginx' 'Pin-Priority: 900' \n  | sudo tee \/etc\/apt\/preferences.d\/99nginx\nsudo apt update\nsudo apt install -y nginx\nsudo systemctl enable --now nginx\nnginx -v\n<\/code><\/pre>\n<p>Pacote nginx.org usa o usu\u00e1rio <code>nginx<\/code> e <code>\/etc\/nginx\/conf.d\/<\/code> \u2014 n\u00e3o tem <code>sites-available<\/code>. O da distro usa <code>www-data<\/code> e o layout Debian. Escolha um e fique nele. O <a href=\"\/2026\/09\/dominando-o-systemd-comandos-essenciais\/\">systemd<\/a> cuida do servi\u00e7o nos dois.<\/p>\n<p>Quer o nginx da distro, com <code>sites-enabled<\/code> e <code>nginx-extras<\/code>? Pule esta se\u00e7\u00e3o e fa\u00e7a <code>sudo apt install nginx<\/code>. O resto do PHP \u00e9 igual; s\u00f3 o dono do socket muda.<\/p>\n<h2>PHP: o DPA do Sury<\/h2>\n<p>Receita oficial de <a href=\"https:\/\/packages.sury.org\/php\/README.txt\">packages.sury.org\/php\/README.txt<\/a> \u2014 vale Debian 12\/13 e Ubuntu 24.04\/26.04:<\/p>\n<pre><code class=\"language-bash\">sudo apt-get update\nsudo apt-get -y install lsb-release ca-certificates curl\ncurl -sSLo \/tmp\/debsuryorg-archive-keyring.deb https:\/\/packages.sury.org\/debsuryorg-archive-keyring.deb\nsudo dpkg -i \/tmp\/debsuryorg-archive-keyring.deb\necho \"deb [signed-by=\/usr\/share\/keyrings\/deb.sury.org-php.gpg] https:\/\/packages.sury.org\/php\/ $(lsb_release -sc) main\" \n  | sudo tee \/etc\/apt\/sources.list.d\/php.list\nsudo apt-get update\n<\/code><\/pre>\n<p>Atalho s\u00f3 Ubuntu (PPA Launchpad do mesmo Ond\u0159ej):<\/p>\n<pre><code class=\"language-bash\">sudo apt install -y software-properties-common\nsudo add-apt-repository -y ppa:ondrej\/php\nsudo apt update\n<\/code><\/pre>\n<p>N\u00e3o ative os dois ao mesmo tempo. Um source de PHP basta.<\/p>\n<p>Tr\u00eas FPM lado a lado + extens\u00f5es t\u00edpicas de WordPress\/Laravel:<\/p>\n<pre><code class=\"language-bash\">sudo apt install -y \n  php8.3-fpm php8.3-cli php8.3-mysql php8.3-xml php8.3-curl php8.3-mbstring php8.3-zip php8.3-gd php8.3-intl php8.3-bcmath \n  php8.4-fpm php8.4-cli php8.4-mysql php8.4-xml php8.4-curl php8.4-mbstring php8.4-zip php8.4-gd php8.4-intl php8.4-bcmath \n  php8.5-fpm php8.5-cli php8.5-mysql php8.5-xml php8.5-curl php8.5-mbstring php8.5-zip php8.5-gd php8.5-intl php8.5-bcmath\nsudo systemctl enable --now php8.3-fpm php8.4-fpm php8.5-fpm\nls \/run\/php\/\n# php8.3-fpm.sock  php8.4-fpm.sock  php8.5-fpm.sock\n<\/code><\/pre>\n<p>CLI padr\u00e3o (o que o <code>php<\/code> sem n\u00famero chama):<\/p>\n<pre><code class=\"language-bash\">sudo update-alternatives --config php\nphp -v\nphp8.5 -v\n<\/code><\/pre>\n<h2>Alinhar o socket com o nginx<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"Diagrama: navegadores chegam no nginx, que roteia para tr\u00eas pools de PHP-FPM no mesmo host\" src=\"\/wp-content\/uploads\/2026\/09\/nginx-varias-versoes-php-fpm.webp\" width=\"1020\" height=\"620\" \/><\/p>\n<p>No nginx.org o worker \u00e9 o usu\u00e1rio <code>nginx<\/code>. O pool padr\u00e3o do FPM \u00e9 <code>www-data<\/code>. Sem alinhar, d\u00e1 502. Em cada pool:<\/p>\n<pre><code class=\"language-bash\">sudo sed -i 's\/^listen.owner.*\/listen.owner = nginx\/' \/etc\/php\/8.4\/fpm\/pool.d\/www.conf\nsudo sed -i 's\/^listen.group.*\/listen.group = nginx\/' \/etc\/php\/8.4\/fpm\/pool.d\/www.conf\n# repita 8.3 e 8.5\nsudo systemctl restart php8.3-fpm php8.4-fpm php8.5-fpm\n<\/code><\/pre>\n<p>Se o nginx for o da distro, deixe <code>www-data<\/code> e pule o <code>sed<\/code>.<\/p>\n<p>Vhost de exemplo \u2014 tr\u00eas sites, tr\u00eas PHPs. No nginx.org o arquivo vai em <code>\/etc\/nginx\/conf.d\/<\/code>:<\/p>\n<pre><code class=\"language-nginx\">server {\n    listen 80;\n    server_name wp.exemplo.com.br;\n    root \/var\/www\/wp.exemplo.com.br;\n    index index.php index.html;\n    location \/ { try_files $uri $uri\/ \/index.php?$args; }\n    location ~ .php$ {\n        try_files $uri =404;\n        include fastcgi_params;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        fastcgi_pass unix:\/run\/php\/php8.3-fpm.sock;\n    }\n}\nserver {\n    listen 80;\n    server_name app.exemplo.com.br;\n    root \/var\/www\/app.exemplo.com.br\/public;\n    index index.php;\n    location \/ { try_files $uri $uri\/ \/index.php?$query_string; }\n    location ~ .php$ {\n        try_files $uri =404;\n        include fastcgi_params;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        fastcgi_pass unix:\/run\/php\/php8.5-fpm.sock;\n    }\n}\n<\/code><\/pre>\n<pre><code class=\"language-bash\">sudo mkdir -p \/var\/www\/wp.exemplo.com.br \/var\/www\/app.exemplo.com.br\/public\necho '&lt;?php phpinfo();' | sudo tee \/var\/www\/wp.exemplo.com.br\/index.php\nsudo nginx -t &amp;&amp; sudo systemctl reload nginx\n<\/code><\/pre>\n<p>Confirme no <code>phpinfo()<\/code> o <em>PHP Version<\/em> e o caminho do <code>php.ini<\/code> (<code>\/etc\/php\/8.3\/fpm\/php.ini<\/code>, etc.). Cada major tem ini pr\u00f3prio \u2014 mudar 8.4 n\u00e3o mexe no 8.5.<\/p>\n<h2>Firewall e o que n\u00e3o fazer<\/h2>\n<pre><code class=\"language-bash\">sudo ufw allow 22,80,443\/tcp\nsudo ufw enable\n<\/code><\/pre>\n<p>N\u00e3o instale <code>libapache2-mod-php*<\/code> neste box. N\u00e3o aponte dois <code>server_name<\/code> iguais para sockets diferentes e espere milagre. N\u00e3o suba PHP 8.1 \u201cporque o plugin pede\u201d: o Sury ainda empacota, mas o upstream acabou. 8.2 s\u00f3 at\u00e9 o fim de 2026.<\/p>\n<p>Painel com nginx+PHP j\u00e1 mastigado: <a href=\"\/2017\/01\/a-historia-do-ispconfig\/\">ISPConfig<\/a>. Este post \u00e9 a caixa nua, sem painel.<\/p>\n<h2>O que ficou<\/h2>\n<p>Um pin no nginx.org, um DPA no Sury, tr\u00eas FPM, tr\u00eas sockets, tr\u00eas <code>server<\/code>. O apt atualiza o ponto; o vhost escolhe o major. Quando o 8.2 sair de seguran\u00e7a, apague o pacote \u2014 o 8.5 no outro vhost nem percebe.<\/p>\n<p>Nginx: <a href=\"https:\/\/nginx.org\/en\/linux_packages.html\">nginx.org\/en\/linux_packages.html<\/a> \u00b7 PHP Sury: <a href=\"https:\/\/packages.sury.org\/php\/\">packages.sury.org\/php<\/a> \u00b7 ciclo PHP: <a href=\"https:\/\/www.php.net\/supported-versions.php\">php.net\/supported-versions<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Debian 12 ships PHP 8.2. Ubuntu 24.04 ships 8.3. Debian 13, 8.4. Ubuntu 26.04, 8.5. A real host needs all three at once: the old WordPress site, the new Laravel application, and the cron CLI. The distribution repository does not allow it. Ond\u0159ej Sur\u00fd\u2019s does. nginx comes from nginx.org \u2014 stable, pinned, without mixing \u2026 <a title=\"Nginx and multiple PHP versions on Debian and Ubuntu\" class=\"read-more\" href=\"https:\/\/www.linuxpro.com.br\/en\/2026\/09\/nginx-varias-versoes-php-debian-ubuntu\/\" aria-label=\"Read more about Nginx e v\u00e1rias vers\u00f5es de PHP no Debian e Ubuntu\">Read more<\/a><\/p>","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,12,2,120,3],"tags":[15,240,237,238,316,5],"class_list":["post-659","post","type-post","status-publish","format-standard","hentry","category-debian","category-lamp","category-linux","category-servidores","category-ubuntu","tag-debian","tag-nginx","tag-php","tag-php-fpm","tag-sury","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/comments?post=659"}],"version-history":[{"count":5,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/659\/revisions"}],"predecessor-version":[{"id":1432,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/posts\/659\/revisions\/1432"}],"wp:attachment":[{"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/media?parent=659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/categories?post=659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxpro.com.br\/en\/wp-json\/wp\/v2\/tags?post=659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}