How to use multiple PHP versions in Apache without using FPM
P粉287345251
P粉287345251 2023-08-16 14:14:17
0
1
413
<p>I have two PHP versions installed on the server, <code>7.2</code> and <code>7.4</code>. Both versions are enabled. </p> <p>There is currently a project using PHP <code>7.2</code>. I need to run a new project using PHP <code>7.4</code>. As I mentioned before, I don't use PHP-FPM. After some research I should use <code>a2dismod php7.2</code> and <code>a2denmod php7.4</code> to stop the <code>7.2</code> version and start <code> ;7.4</code> version. But in this case, the currently running project will stop working because it is compatible with version <code>7.2</code>. </p> <p>So, is there a way to configure Apache without using PHP-FPM so that it can handle two different projects running on the same server, one using PHP <code>7.2</code>, Another one using <code>7.4</code>? </p>
P粉287345251
P粉287345251

reply all(1)
P粉138711794

When using PHP as an Apache module, as far as I know, only one PHP module can be loaded per server instance.

However, similar to PHP-FPM, you can run two Apache server instances. One is configured with PHP 7.2 modules and the other is configured with PHP 7.4 modules.

Assuming the PHP 7.2 module for Apache is the current server instance, it will proxy the PHP 7.4 application's virtual host to the new second Apache server instance.

This is similar to Nginx and two PHP-FPMs, just using different Apache and Apache layouts.

+----------------------------------------------------+
         |                       +-------------+ + pool #1    |
         |                ,----> | PHP-FPM 7.2 | + pool #2    |
         |   +-------+ <--'      +-------------+ + ...        |
  WAN <====> | Nginx |     FCGI                               |
         |   +-------+ <--.      +-------------+ + pool #1    |
         |                '----> | PHP-FPM 7.4 | + ...        |
         |                       +-------------+              |
         +----------------------------------------------------+
+-------------------------------------------------+  
         |    +-------------+            +-------------+   |
  WAN <=====> | Apache #1   | <--------> | Apache #2   |   |
         |    |.............|    HTTP    |.............|   |
         |    | mod PHP 7.2 |            | mod PHP 7.4 |   |
         |    +-------------+            +-------------+   |
         +-------------------------------------------------+

As far as I know, you can only use standard utilities like a2denmod(1) for the main server instance. So please familiarize yourself with the server configuration, Apache has great documentation and I personally like its configuration a lot. Probably because I've been using it since about Apache 1.3.

However, since it is 2023, Nginx PHP-FPM is a very good combination. The original Nginx is a pretty good and powerful tool.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!