Installing PHPBrew into System wide Environment
Sometimes you want to share the pre-installed php(s) for your users on the same machine, you can use phpbrew to pre-install php(s) as root and let your user specifies the php version.
So there is the steps let you install phpbrew as system-wide version manager:
First, sudo as a root user or login as a root user:
sudo -i
Now initialize your phpbrew bashrc for root:
phpbrew init
Now export phpbrew paths to your desired paths, edit your ~/.phpbrew/bashrc
export PHPBREW_ROOT=/opt/phpbrew # php dist files and build files are stored here
export PHPBREW_HOME=/root/.phpbrew # your configuration files.
Source your phpbrew bashrc
source ~/.phpbrew/bashrc
Now install system-wide php(s):
phpbrew install php-5.4.5 +default +dbs
Now your php(s) will be installed under the /opt/phpbrew path, to allow your system users to use php(s) built by phpbrew, you need to export PHPBREW_ROOT and PHPBREW_HOME environment in /etc/bashrc or in /etc/profile.d/phpbrew for bash users, before they load the phpbrew/bashrc file.
export PHPBREW_ROOT=/opt/phpbrew
export PHPBREW_HOME=$HOME/.phpbrew
source /opt/phpbrew/bashrc
To keep your system secure, please use root to install php(s).
a non-root user should not be able to install new php or switch
and remember to fix permissions if these files were installed by non-root user.
chown -R root: /opt/phpbrew