Use context for different PHP version

#1
Hi there!

I'm trying something that I don't know if already feasible with OLS and I don't find much good documentation about.

I have one wordpress accesible via domainA.cat which is executed with PHP8.2 and PHP execution user is sense9761.

Then I have one Laravel installed in another server folder that I want to be accessible via domainA.cat/ticketing.

This first part it's OK using context.

The second part I don't get is I want that app inside /ticketing is executed by user entra5298 and PHP8.1

It seems this context will be always executed by "parent" lsphp

Here is my (chunked) vHost file:

Code:
docRoot                   $VH_ROOT/public_html
vhDomain                  $VH_NAME
vhAliases                 www.$VH_NAME
adminEmails               admin@localhost
enableGzip                1
enableIpGeo               1

index  {
  useServer               0
  indexFiles              index.php, index.html
}

scripthandler  {
  add                     lsapi:sense9761 php
}

extprocessor sense9761 {
  type                    lsapi
  address                 UDS://tmp/lshttpd/sense9761.sock
  maxConns                10
  env                     LSAPI_CHILDREN=10
  initTimeout             600
  retryTimeout            0
  persistConn             1
  pcKeepAliveTimeout      1
  respBuffer              0
  autoStart               2
  path                    /usr/local/lsws/lsphp82/bin/lsphp
  extUser                 sense9761
  extGroup                sense9761
  memSoftLimit            2047M
  memHardLimit            2047M
  procSoftLimit           400
  procHardLimit           500
}

extprocessor entra5298 {
  type                    lsapi
  address                 UDS://tmp/lshttpd/entra5298.sock
  maxConns                10
  env                     LSAPI_CHILDREN=10
  initTimeout             600
  retryTimeout            0
  persistConn             1
  pcKeepAliveTimeout      1
  respBuffer              0
  autoStart               1
  path                    /usr/local/lsws/lsphp81/bin/lsphp
  extUser                 entra5298
  extGroup                entra5298
  memSoftLimit            2047M
  memHardLimit            2047M
  procSoftLimit           400
  procHardLimit           500
}

context /ticketing/ {

  location                /home/entrades.domainA.cat/app/current/public
  allowBrowse             1
  indexFiles              index.php, index.html
  addDefaultCharset       off
  type                    lsapi
  handler                 entra5298
}

rewrite  {
  enable                  1
  autoLoadHtaccess        1
}
Any suggestion? Is that possible in OSL?

Thanks!
 
#3
Thanks @Cold-Egg !! It made my day!

I could manage it. But I needed to adapt it. For instance: the example uses a Force Mime but I wanted the assets to be served as it. So I added a "Mime Type" during the context definition.

But very good point to start.

Thanks you very much!
 
#4
I open the thread again, sorry.

Actually what I said about adding mime type on context to apply the rule only on php files it's not true.

It seems all requests, including assets, are handled by php. Check:

Code:
curl -I https://domainA.cat/ticketing/img/beta-1.png

HTTP/2 200 
x-powered-by: PHP/8.2.8
content-type: text/html; charset=UTF-8
date: Wed, 26 Jul 2023 06:30:02 GMT
server: LiteSpeed
Obviously I would like to serve assets as static files and force mime type only on php files of this context in order to execute them with the proper PHP version.

Any tip @Cold-Egg ?? Anyone??

Thanks!
 

Cold-Egg

Administrator
#5
Hi,
Because every file under that folder matches the context, Force MIME Type is applied to all.
If you want to match all the php files only, please replace /ticketing/ with exp:^/$|.*\.php$
Let me know if it works.
 
Top