Variable containing document root

Discussion in 'General' started by Gerry, Nov 15, 2010.

  1. Gerry

    Gerry Active Member

    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:


    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:
            ServerName subdomain.domain.tld
            DocumentRoot /web/username/domain.tld/subdomain
            SuexecUserGroup web-username web
            AddType application/x-httpd-php5 php
  2. NiteWave

    NiteWave Administrator

    you can use
    to customize default system-wide php.ini for each virtual host.

    this is a lsphp special feature, comparing with other php fastcgi implementation.
  3. Gerry

    Gerry Active Member

    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
    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.
  4. NiteWave

    NiteWave Administrator

    assume php in suExec mode? since lsws 4.0.2:
    maybe just what you want.
  5. Gerry

    Gerry Active Member

    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.
  6. mistwang

    mistwang LiteSpeed Staff

    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.
  7. NiteWave

    NiteWave Administrator

    where did you set them ?

    It looks there is a ideal solution for your request. But I'd ask you the above question first.
  8. Gerry

    Gerry Active Member

    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:

        # Default VirtualHost
        DocumentRoot /web/default/
        SuexecUserGroup web-user web
    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".
  9. webizen

    webizen Well-Known Member

    put "PHP_INI_SCAN_DIR=$VH_ROOT/..." on 3rd line of Ext App Environment should do it. e.g.

    This is a workaround in 4.0.17. It will be fixed in 4.0.18.
    Last edited: Nov 26, 2010
  10. NiteWave

    NiteWave Administrator


    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.
  11. Gerry

    Gerry Active Member

    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!
  12. NiteWave

    NiteWave Administrator

    $VH_ROOT/DEFAULT is an example. $DOC_ROOT also ok.
  13. Gerry

    Gerry Active Member

    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/.
  14. mistwang

    mistwang LiteSpeed Staff

    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.
  15. Gerry

    Gerry Active Member

    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.
  16. mistwang

    mistwang LiteSpeed Staff

    It can only be customized per user account, not possible to be per sub-domain.

Share This Page