[Resolved] Use different PHP version on particular directory of virtualhost.

Status
Not open for further replies.
#1
Title says it all. Using Litespeed Web Server Standard 5.1.4. I have virtual host configured:

Code:
http://sv1.domain.com/subdir-1/
http://sv1.domain.com/subdir-2/
http://sv1.domain.com/subdir-3/
...
Globally I'm using php 5.6.x but for some directories I want to use php 7. Tried to play with context settings like this:



No idea why it's not working...This brings me error:

Code:
Warning:Unknown: failed to open stream:No such file or directory inUnknown on line 0
Fatal error:Unknown:Failed opening required 'LS'(include_path='.:/usr/local/lsws/lsphp7/lib/php')inUnknown on line 0
I can switch betveew php version globaly, also I can switch it for different virtual host, but not for directories inside particular virtual host, I'm pretty sure this is possible.
 
#3
Not really helpful link, I'm not novice, but information there is to complex to understand for first time configuration, maybe there is some step by step guide tu configure lsws for more then 1 php version in same virtual host?
 
#4
And I'm not even running any server control panel. Here is my server level External app configuration, I can swith in Virtual Host level and everything is working.


Here is my Virtual host Script Handler


Well I can set it to lsphp7 and it will switch to php 7.
From here I'm stuck, how hard can it be, very un-intuitive or maybe I'm missing some fundamentals knowledge.
 
L

Long

Guest
#5
Hi, simply speaking, you need to achieve your goal through .htaccess manipulation.

First, you need to create server level lsphp7,5 external apps and corresponding script handlers.

Then in the .htaccess file in the directory you want to customize the php handler, use the directives AddType, AddHandler or ForceType to manipulate php files extension MIME mapping so that they will be processed by the corresponding handler.
 
#6
Ok, so I did it and now can achieve this by adding .htaccess file to desired directory, inside that .htaccess:

Code:
AddHandler application/x-httpd-php7 php
But I need to do it without editing or creating .htaccess. I tried to set this inside Virtual host rewrite rule section, it's also working, but for all virtual host, not for specific directory.

I need something like this:

Code:
<Directory "/home/www/domain.com/subdir-1">
    AddHandler application/x-httpd-php7 php
</Directory>
 

NiteWave

Administrator
#7
I did a test, looks working after configure as below:
a) virtual host -> Context, Add, select type Static
b) URI: /subdir-1/
Location: subdir-1/
Allow Override: Check FileInfo
Apache Style configurations:AddHandler application/x-httpd-php7 php
 
#8
I did a test, looks working after configure as below:
a) virtual host -> Context, Add, select type Static
b) URI: /subdir-1/
Location: subdir-1/
Allow Override: Check FileInfo
Apache Style configurations:AddHandler application/x-httpd-php7 php
Working, thanks.
 
Status
Not open for further replies.
Top