Change apache (PHP) $PATH environment variable on CentOS with cPanel

7,044

Solution 1

It actually was combination of 3 things:

  1. Installation must be mod_php
  2. Then the config file on CentOS with cPanel is /usr/local/apache/bin/envvars; and usual export PATH=$PATH:/path works just fine here
  3. You need to stop/start httpd service, simple restart will not change the environmental variables

Thanks for help!

Solution 2

Edit /opt/suphp/etc/suphp.conf and set env_path to the path string that you want.

Share:
7,044
Michal Gow
Author by

Michal Gow

Updated on September 18, 2022

Comments

  • Michal Gow
    Michal Gow over 1 year

    I need to add a path to $PATH environment variable for PHP scripts on CentOS linux server with cPanel Pro 1.0 and Apache 2.2.27.

    For Ubuntu or SuSE it just means adding the row export PATH=$PATH:/path to /etc/sysconfig/apache2, but this file is missing in sysconfig on CentOS with cPanel (and, of course, script /etc/init.d/httpd is not looking for it). Is it anywhere else (as that would be the solution)?

    The answer published here uses PHP itself to change PATH variable, but I'd like to use more robust solution on the Apache level... Any help will be highly appreciated!

    • Florin Asăvoaie
      Florin Asăvoaie about 10 years
      It is important to mention how are you running PHP, is it suPHP, or mod_php?
  • Michal Gow
    Michal Gow about 10 years
    Invalid command 'env_path'...
  • Michal Gow
    Michal Gow about 10 years
    What if I change Apache to mod_php? Would that help? It is VPS with only one website, so it is actually even logical choice...
  • Florin Asăvoaie
    Florin Asăvoaie about 10 years
    It is not. suPHP has many advantages over mod_php. Maybe update the suPHP version? It should definitely support that command, see here.