Last active
December 11, 2018 14:08
-
-
Save renatomefi/e71eb87ad83a8d16bf0e to your computer and use it in GitHub Desktop.
Alternatives install for PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ------------------------------------------------------------------ | |
# [Author] Renato Mefi <[email protected]> | |
# https://github.com/renatomefi | |
# | |
# [Desc] Configure alternatives for PHP Installations | |
# Very usefull when you are building your PHP and don't want to use | |
# more sofsticated softwares like 'phpbrew', 'php-build', 'php-env' ... | |
# | |
# [Usage] ./php-alternatives-install.sh /path/for/php/installation 200 | |
# | |
# [I.E.] ./php-alternatives-install.sh /opt/php/php-5.6.8 200 | |
# ./php-alternatives-install.sh /opt/php/php-7.0.0-dev 1 | |
# | |
# $sudo alternatives --config php | |
# There are 2 programs which provide 'php'. | |
# | |
# Selection Command | |
# ----------------------------------------------- | |
# * 1 /opt/php/php-5.6.8/bin/php | |
# + 2 /opt/php/php-7.0.0-dev/bin/php | |
# | |
# Enter to keep the current selection[+], or type selection number: 2 | |
# | |
# [Download] https://gist.github.com/renatomefidf/e71eb87ad83a8d16bf0e/download | |
# | |
LINKDIR=/usr/bin | |
PHPPATH=$1 | |
PHPBIN=$PHPPATH/bin | |
[ -z $2 ] && PRIORITY=20000 || PRIORITY=$2 | |
echo "Installing alternatives for PHP at $LINKDIR from $PHPBIN" | |
echo "With priority of $PRIORITY"; | |
sudo alternatives --install $LINKDIR/php php $PHPBIN/php $PRIORITY \ | |
--slave $LINKDIR/php-cgi php-cgi $PHPBIN/php-cgi \ | |
--slave $LINKDIR/php-config php-config $PHPBIN/php-config \ | |
--slave $LINKDIR/phpize phpize $PHPBIN/phpize \ | |
--slave $LINKDIR/phar.phar phar.phar $PHPBIN/phar.phar \ | |
--slave $LINKDIR/phar phar $PHPBIN/phar \ | |
--slave $LINKDIR/pecl pecl $PHPBIN/pecl \ | |
--slave $LINKDIR/pear pear $PHPBIN/pear \ | |
--slave $LINKDIR/peardev peardev $PHPBIN/peardev | |
echo "Current alternatives for PHP" | |
alternatives --display php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment