skip to Main Content

I need to add an additional path to my Apache configuration for PHP. Ideally, it would be Serverwide but as I’m using ServerPilot it’s easier to just affect the individual VirtualHosts.

The Path is currently set to PATH /opt/sp/php7.3/bin:/sbin:/usr/sbin:/bin:/usr/bin but I need to additionally add /opt/sqlanywhere17/res

eg /opt/sp/php7.3/bin:/sbin:/usr/sbin:/bin:/usr/bin:/opt/sqlanywhere17/res

I have tried adding

export PATH=$PATH:/opt/sqlanywhere17/res but apache fails to start

What syntax do I need to use in the VirtualHosts .conf file to make this work???

2

Answers


  1. You can set env variblae using SetEnv in Apache httpd.

    SetEnv VARIABLE_NAME variable_value
    

    Refer link for more information.

    You can set path environment variable inside VirtualHost.

    SetEnv path  /opt/sp/php7.3/bin:/sbin:/usr/sbin:/bin:/usr/bin:/opt/sqlanywhere17/res
    
    

    Then you can retrieve the path variable in PHP using below sample code:

    <?php
    $path = getenv("path");
    echo $path;
    ?>
    
    Login or Signup to reply.
  2. To append a path to the PATH env var, you can do this:

    SetEnv PATH "${PATH}:/my/nifty/path/bin"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search