Skip to main content

Problems setting vhost environment variables in Apache

Comments

5 comments

  • cPRex Jurassic Moderator

    Hey there!  It's important to note that you can't modify or delete anything inside /home/virtfs, so please don't try to edit the files there.

    I would expect any file you create ending in ".conf" to be loaded properly in the include system, and unless the default Apache template has been modified there is no way that it won't be read.  You'll see the following line at the end of each Apache vhost inside the main /etc/apache2/conf/httpd.conf file:

      # To customize this VirtualHost use an include file at the following location
    # Include "/etc/apache2/conf.d/userdata/ssl/2_4/username/domain.com/*.conf"
    </VirtualHost>

    It's also worth noting that there is both the SSL and non-SSL vhost, so make sure you editing both just to be consistent and avoid confusion.

    I would recommend trying to add something that isn't related to the mod_env system just to see if that takes affect - that would at least narrow down the issue to a problem with the include or with mod_env.

    0
  • theWoosh

    Thanks cPRex - I am using the SSL vhost exclusively here. Turns out they are getting set I was looking in the environment section when I did a phpinfo.php to check. They are showing up in the PHP variables section as like:
    $_SERVER['DB_HOST']    localhost

    0
  • cPRex Jurassic Moderator

    Great - so things are working as expected?

    0
  • theWoosh

    Sure are! Sometimes I get frustrated when I find myself spending more time working round CPanel (and it's ilk) because they just don't let me do the things I am used to doing directly (like adding something to the standard vhosts conf)! Alls well that ends well...

    0
  • cPRex Jurassic Moderator

    Oh for sure, I get that.  I just tell people to remember that those systems are in place because cPanel has to integrate with everything on the machine, so direct edits in the "usual" way don't interact well.

    0

Please sign in to leave a comment.