Variable containing document root

Gerry

Active Member
#1
We are trying to have a default system-wide php.ini to which values can be added per virtual host by having a php.ini in that host's document root. The PHP_INI_SCAN_DIR variable is ideal for that.

We tried setting that variable to $VH_NAME, $VH_ROOT or $DOC_ROOT, unfortunately none of them contain the right value. Our structure is as follows for a user "username" and vhost subdomain.domain.tld:

/web/username/domain.tld/subdomain/

The variables contain the following:
$VH_NAME is empty
$VH_ROOT /web/username/
$DOC_ROOT /web/username/domain.tld/default/ (no clue where 'default' comes from)

Any idea how I could get /web/username/domain.tld/subdomain/ out of a variable?

NB: we are using an Apache-style configuration which looks like this:
Code:
<VirtualHost 12.34.56.78:80>
        ServerName subdomain.domain.tld
        DocumentRoot /web/username/domain.tld/subdomain
        SuexecUserGroup web-username web

        AddType application/x-httpd-php5 php
</VirtualHost>
 

Gerry

Active Member
#3
Thank you for your reply, however, I don't want to configure the PHP variables in the virtual host configuration, I want our customers to have their own php.ini file in which they can override the values in our system-wide php.ini.

More specifically, some customers want to load a specific module to run encoded PHP files (ex: IonCube). This can not be done with .user.ini files, it can only be done by setting the PHP_INI_SCAN_DIR as an environment variable. This works perfectly if I do
Code:
PHP_INI_SCAN_DIR=$VH_ROOT
but this is not where I want to have the file. /web/username is not writable for the user and I want the php.ini to be per subdomain, so I want it in /web/username/domain.tld/subdomain/

What I would need is a variable like $VH_ROOT containing the value of the DocumentRoot directive in our virtual host config so I can set the PHP_INI_SCAN_DIR environment variable to that value.
 

NiteWave

Administrator
#4
assume php in suExec mode? since lsws 4.0.2:
(For suEXEC only) Added support for PHPIniDir directive at virtual host level to allow customized php.ini.
(For suEXEC only) Added support for PHPRC environment variable to customize php.ini.
maybe just what you want.
 

Gerry

Active Member
#5
Thank you for your answer, this is indeed almost what I want and I tried that already, but not quite.

The PHPIniDir directive and PHPRC variable both allow you to use a completely different php.ini file. I want to use a system-wide php.ini file, and on top of that allow the user to have its own php.ini file to overwrite the defaults.
This is basically what PHP_INI_SCAN_DIR allows you to do.

If I would have a variable containing the right value (the value of DocumentRoot in the vhost config), I could point the PHP_INI_SCAN_DIR environment variable to the directory I want to have.
 

mistwang

LiteSpeed Staff
#6
Are you configure everything in LSWS native configuration? using vhost templates?
I think "default" was added somewhere, grep the whole "conf" directory see if you can find it.
If you are sure it is not a configuration issue, please let our staff know how to exactly replicate your setup in our lab to reproduce it.
 

Gerry

Active Member
#8
Sorry for the late reply, I've been busy with other issues.

We are using Apache-style configuration for our virtual hosts.

The only place where I can find a reference to "default" in our configuration is in the default vhost config:

Code:
<VirtualHost 11.22.33.44:80>
    # Default VirtualHost
    DocumentRoot /web/default/
    SuexecUserGroup web-user web
</VirtualHost>
The default vhost is used when accessing our webserver without it being configured. It shows a page asking to have some patience before the config is reloaded. I'd like to keep that. :)

We used the variables in the "Environment" configuration of our php "External App".
 

webizen

Well-Known Member
#9
put "PHP_INI_SCAN_DIR=$VH_ROOT/..." on 3rd line of Ext App Environment should do it. e.g.

Code:
...
...
PHP_INI_SCAN_DIR=$VH_ROOT/DEFAULT
...
This is a workaround in 4.0.17. It will be fixed in 4.0.18.
 
Last edited:
#10
Gerry:

please try 4.0.18, "PHP_INI_SCAN_DIR=$VH_ROOT/DEFAULT" in lsphp environment now working well, and as you said this is ideal solution you wanted.
 

Gerry

Active Member
#11
Hello NiteWave,

Unfortunately, after upgrading I don't see any difference in the value of the variables.
Also, I don't understand what you mean by "$VH_ROOT/DEFAULT". I don't want to append /DEFAULT to anything, what I would like is a variable containing the value of the DocumentRoot directive in our Apache config, that is all. :)

Thanks for your feedback!
 

Gerry

Active Member
#13
Unfortunately, the contents of the $DOC_ROOT variable is also unchanged. This is still /web/username/domain.tld/default instead of the actual value of the DocumentRoot directive in our configuration which is /web/username/domain.tld/subdomain/.
 

mistwang

LiteSpeed Staff
#14
For each user account, only one set of PHP suEXEC processes will be created, it wont be per subdomain. So, the document root of the first vhost, usually the main vhost, will be used for the PHP suEXEC environment.
PHP suEXEC is not per subdomain, but per user account, it is to avoid creating too many PHP processes for user creating more subdomains. The variable substitution takes place during configuration, not at runtime.
 

Gerry

Active Member
#15
Thank you mistwang for the clarification. I understand why it won't work this way.

Aside from having a different user for each subdomain (which is not possible at all in our setup), do you have any idea how we could achieve this? If I'm not mistaken, it would work in Apache (although I never tested it) since you can specify the PHP environment variables in your vhost configuration.
 
Top