使用两个 php 版本(v7.2、v5.6)而不创建子域

use two php versions(v7.2, v5.6) without create of subdomain

我必须在 Laravel 中升级我的网站,它使用 PHP 7.2 并指向根目录 (public_html)。 在 root(public_html) 目录中,我有一个文件夹 "portal",它是 Codeigniter 中的一个单独模块,它使用 PHP 5.6

有什么方法可以让我在根文件夹 (public_html) 和 PHP 上应用 PHP 7.2 5.6 仅在 portal 文件夹中。

喜欢 http://www.webiste.com/ 与 PHP7.2

一起工作

http://www.webiste.com/portal 使用 PHP5.6

谢谢

您可以在每个文件夹中使用 .htaccess 文件,并使用 AddHandler:[=14= 指定 php 处理程序(在指定的 php 版本中) ]

/.htaccess

# PHP 7.2
AddHandler x-httpd-php72 .php

/portal/.htaccess

# PHP 5.6
AddHandler x-httpd-php56 .php

这里是确切的代码

将此代码放在子域文件夹中 .htaccess 文件的底部

<IfModule mime_module>
     AddHandler application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>

将此代码放在“public_html”文件夹的 .htaccess 文件底部

<IfModule mime_module>
    AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>

Php 文件内容显示而不是 运行 代码? , 使用此方法

<?php

use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
    require __DIR__.'/../storage/framework/maintenance.php';
}

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/

require __DIR__.'/../vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/

$app = require_once __DIR__.'/../bootstrap/app.php';

$kernel = $app->make(Kernel::class);

$response = tap($kernel->handle(
    $request = Request::capture()
))->send();

$kernel->terminate($request, $response);