Múltiples PHP en Ubuntu con Apache (7.4–8.4)

Guía para instalar y gestionar múltiples PHP en Ubuntu con Apache y PHP-FPM (7.4–8.4), con buenas prácticas, comandos prácticos y recomendaciones de despliegue en la nube.

18 sept 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Múltiples PHP en Ubuntu con Apache (7.4–8.4) Este artículo explica cómo instalar y gestionar varias versiones de PHP en Ubuntu con Apache y PHP-FPM, y además describe buenas prácticas para entornos de desarrollo y producción. Q2BSTUDIO es una empresa de desarrollo de software especializada en aplicaciones a medida, inteligencia artificial, ciberseguridad y servicios cloud. Si necesita integrar aplicaciones web con múltiples versiones de PHP o desarrollar soluciones personalizadas puede visitar nuestros servicios de desarrollo de aplicaciones y software a medida y para desplegar en la nube explore nuestros servicios cloud en AWS y Azure.

1 Añadir PPA de PHP Actualice el cache y agregue el repositorio mantenido por Ondrej. Comandos típicos: sudo apt update, sudo apt install -y software-properties-common ca-certificates lsb-release apt-transport-https, sudo add-apt-repository -y ppa:ondrej/php, sudo apt update.

2 Instalar versiones de PHP Instale las versiones que necesite. Ejemplos: sudo apt install -y php7.4 php7.4-cli php7.4-fpm, sudo apt install -y php8.0 php8.0-cli php8.0-fpm, sudo apt install -y php8.1 php8.1-cli php8.1-fpm, sudo apt install -y php8.2 php8.2-cli php8.2-fpm, sudo apt install -y php8.3 php8.3-cli php8.3-fpm, sudo apt install -y php8.4 php8.4-cli php8.4-fpm.

3 Instalar extensiones importantes Para cubrir frameworks como Laravel y Symfony, CMS como WordPress y Drupal, y otras necesidades de negocio instale extensiones comunes reemplazando X.X por la versión deseada. Ejemplo: sudo apt install -y phpX.X-cli phpX.X-fpm phpX.X-mysql phpX.X-xml phpX.X-curl phpX.X-mbstring phpX.X-zip phpX.X-bcmath phpX.X-gd phpX.X-intl phpX.X-readline phpX.X-soap phpX.X-opcache phpX.X-dev phpX.X-imagick phpX.X-pgsql phpX.X-sqlite3. Estas extensiones cubren procesamiento de imágenes, drivers de bases de datos y mejoras de rendimiento, útiles para proyectos de inteligencia artificial, automatización de procesos y servicios de inteligencia de negocio.

4 Comprobar versiones instaladas Verifique la versión CLI actual con php -v. Liste alternativas con update-alternatives --list php. Consulte servicios PHP-FPM en ejecución con systemctl list-units | grep php. Compruebe extensiones cargadas con php -m.

5 Cambiar versión PHP para CLI Para una selección interactiva utilice sudo update-alternatives --config php. Para establecer directamente una versión use por ejemplo sudo update-alternatives --set php /usr/bin/php8.3. Verifique con php -v.

6 Cambiar versión PHP para Apache (PHP-FPM) Para Apache habilite o deshabilite servicios FPM según la versión que quiera servir. Ejemplos: sudo systemctl stop php7.4-fpm, sudo systemctl enable --now php8.3-fpm. Active módulos y configuraciones de Apache: sudo a2enmod proxy_fcgi setenvif, sudo a2enconf php8.3-fpm, sudo a2disconf php7.4-fpm, sudo systemctl reload apache2. En un VirtualHost puede usar algo como <FilesMatch \.php$> SetHandler proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/ </FilesMatch>. Luego reinicie Apache con sudo systemctl restart apache2.

7 Probar PHP Cree un archivo de prueba en el directorio web público, por ejemplo sudo tee /var/www/html/info.php > /dev/null <<PHP EOT<?php phpinfo(); ?>PHP EOT o cree manualmente el archivo con el contenido <?php phpinfo(); ?> y abra en el navegador la ruta https://localhost/info.php para verificar que Apache está entregando la versión FPM correcta.

Referencia rápida Cambiar PHP CLI sudo update-alternatives --config php. Cambiar PHP para Apache FPM ejemplos sudo systemctl stop php8.0-fpm, sudo systemctl start php8.2-fpm, sudo a2enconf php8.2-fpm, sudo a2disconf php8.0-fpm, sudo systemctl reload apache2.

Buenas prácticas y recomendaciones Mantenga las versiones que necesite instaladas pero desactive servicios FPM no usados para reducir la superficie de ataque. Automatice pruebas y despliegues para cada versión con pipelines CI/CD y use monitoreo y backups. Si su proyecto requiere integración con soluciones de analítica o Power BI o necesita agentes IA para automatizar tareas, Q2BSTUDIO puede ayudar a diseñar la arquitectura y la integración con servicios de inteligencia de negocio y herramientas de visualización. Podemos colaborar en automatización de procesos y seguridad para entornos PHP modernos, incluyendo auditorías y pentesting.

Sobre Q2BSTUDIO Q2BSTUDIO ofrece desarrollo de software a medida, aplicaciones a medida, inteligencia artificial para empresas, ciberseguridad, servicios cloud AWS y Azure, servicios de inteligencia de negocio y soluciones de automatización. Si desea una consultoría o un proyecto a medida contacte con nosotros para diseñar la solución adecuada a sus necesidades.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat