Change apache (PHP) $PATH environment variable on CentOS with cPanel
7,044
Solution 1
It actually was combination of 3 things:
- Installation must be mod_php
- Then the config file on CentOS with cPanel is
/usr/local/apache/bin/envvars
; and usualexport PATH=$PATH:/path
works just fine here - 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.
Author by
Michal Gow
Updated on September 18, 2022Comments
-
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 about 10 yearsIt is important to mention how are you running PHP, is it suPHP, or mod_php?
-
-
Michal Gow about 10 yearsInvalid command 'env_path'...
-
Michal Gow about 10 yearsWhat 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 about 10 yearsIt is not. suPHP has many advantages over mod_php. Maybe update the suPHP version? It should definitely support that command, see here.