在同一台装有Apache的Ubuntu 18.04服务器上安装两个不同版本的PHP。

huangapple go评论91阅读模式
英文:

two versions of PHP on the same Ubuntu 18.04 server with Apache

问题

以下是翻译好的内容:

我有一台安装了Ubuntu 18.04的服务器,其中托管了两个应用程序,一个使用PHP 7.0,另一个使用PHP 8.0。我按照几份详细说明了PHP-FPM的指南进行了操作,所有步骤都正确执行,没有报错,但在浏览器中检查时,两者都显示版本8.0。你能帮我解决这个问题吗?

英文:

I have a server with Ubuntu 18.04 on which I host two applications, one works with PHP 7.0 and the other with PHP 8.0. I have followed several guides where they explain in detail what to do with PHP-FPM and I do all the steps correctly without throwing errors but when checking in the browser it shows me version 8.0 for both. Could you help me with this?” Is there anything else you would like to know?

these are the virtual hosts

<VirtualHost *80:>
    ServerName certificacion.local
    DocumentRoot /var/www/certificacion.local

    <Directory /var/www/certificacion.local>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

    ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/run/php/php7.0-fpm.sock|fcgi://localhost/var/www/certificacion.local"

    ErrorLog ${APACHE_LOG_DIR}/certificacion.local-error.log
    CustomLog ${APACHE_LOG_DIR}/certificacion.local-access.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerName fiscalizacion.local
    DocumentRoot /var/www/fiscalizacion.local

    <Directory /var/www/fiscalizacion.local>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

    ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/run/php/php8.0-fpm.sock|fcgi://localhost/var/www/fiscalizacion.local"

    ErrorLog ${APACHE_LOG_DIR}/fiscalizacion.local-error.log
    CustomLog ${APACHE_LOG_DIR}/fiscalizacion.local-access.log combined
</VirtualHost>`

i tried to configure PHP-FPM

答案1

得分: 2

这是它对我有效的方式

<VirtualHost *:80>
    DocumentRoot "/var/www/qa-laravel/public"
    ServerName .....local
    <Directory "/var/www/qa-laravel/public">
        AllowOverride All
        Options Indexes FollowSymLinks
        Order allow,deny
        Allow from all
    </Directory>
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhos
    </FilesMatch>
</VirtualHost>

检查 PHP-FPM 服务:确认两个 PHP 版本的 PHP-FPM 服务正常运行。

service php7.0-fpm status
service php8.0-fpm status
英文:

That's how it works for me

&lt;VirtualHost *:80&gt;
    DocumentRoot &quot;/var/www/qa-laravel/public&quot;
        ServerName .....local
        &lt;Directory &quot;/var/www/qa-laravel/public&quot;&gt;
                AllowOverride All
                Options Indexes FollowSymLinks
                Order allow,deny
                Allow from all
        &lt;/Directory&gt;
             &lt;FilesMatch \.php$&gt;
                    SetHandler &quot;proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhos&gt;
            &lt;/FilesMatch&gt;
    
    &lt;/VirtualHost&gt;

Check PHP-FPM service: Confirm that the PHP-FPM services for both PHP versions are running properly.

 service php7.0-fpm status
 service php8.0-fpm status

huangapple
  • 本文由 发表于 2023年6月8日 10:03:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76428138.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定