【问题标题】:use two php versions(v7.2, v5.6) without create of subdomain使用两个 php 版本(v7.2、v5.6)而不创建子域
【发布时间】:2020-08-14 10:38:00
【问题描述】:

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

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

喜欢 http://www.webiste.com/ 使用 PHP7.2

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

谢谢

【问题讨论】:

    标签: php laravel codeigniter subdomain cpanel


    【解决方案1】:

    这里是确切的代码

    将此代码放在子域文件夹中 .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>
    

    【讨论】:

      【解决方案2】:

      显示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);
      

      【讨论】:

        【解决方案3】:

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

        /.htaccess

        # PHP 7.2
        AddHandler x-httpd-php72 .php
        

        /portal/.htaccess

        # PHP 5.6
        AddHandler x-httpd-php56 .php
        

        【讨论】:

          猜你喜欢
          • 2021-09-01
          • 1970-01-01
          • 1970-01-01
          • 2015-01-19
          • 2020-11-30
          • 2011-10-08
          • 2010-10-09
          • 2016-04-18
          相关资源
          最近更新 更多