Last active
January 21, 2018 11:49
-
-
Save nhuhoai/04269ab2f97ab7afd9833278a6a34a25 to your computer and use it in GitHub Desktop.
Install PHP5.6, PHP7.0 & PHP7.1 for Debian
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 | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root, use sudo "$0" instead" 1>&2 | |
exit 1 | |
fi | |
echo 'Add ondrej repository for PHP' | |
add-apt-repository ppa:ondrej/php -y > /dev/null | |
echo 'Update packages' | |
apt-get update > /dev/null | |
echo 'Install Apache2' | |
apt-get install apache2 -y > /dev/null | |
echo 'Install MySQL server & client' | |
apt-get install mysql-server -y | |
echo 'Install SQLite client' | |
apt-get install sqlite -y > /dev/null | |
echo 'Install PHP5.6' | |
apt-get install php5.6-dev php5.6-mysql php5.6-sqlite php5.6-gettext php5.6-mbstring libapache2-mod-php5.6 -y > /dev/null | |
echo 'Install PHP7.0' | |
apt-get install php7.0-dev php7.0-mysql php7.0-sqlite php7.0-gettext php7.0-mbstring libapache2-mod-php7.0 -y > /dev/null | |
echo 'Install PHP7.1' | |
apt-get install php7.1-dev php7.1-mysql php7.1-sqlite php7.1-gettext php7.1-mbstring libapache2-mod-php7.1 -y > /dev/null | |
echo 'Install XDebug' | |
apt-get install php-xdebug -y > /dev/null | |
echo 'Install PHPUnit 5' | |
wget -O /usr/local/bin/phpunit-5 https://phar.phpunit.de/phpunit-5.phar > /dev/null | |
chmod ugo+x /usr/local/bin/phpunit-5 > /dev/null | |
echo 'Install PHPUnit 6' | |
wget -O /usr/local/bin/phpunit-6 https://phar.phpunit.de/phpunit-6.phar > /dev/null | |
chmod ugo+x /usr/local/bin/phpunit-6 > /dev/null | |
echo 'Add phpinfo.php to the web root directory' | |
echo '<?php phpinfo(); ?>' > /var/www/html/phpinfo.php | |
echo 'Add script for switching to PHP5.6' | |
echo '#!/bin/bash' > /usr/local/bin/php5.6 | |
echo 'if [[ $EUID -ne 0 ]]; then' >> /usr/local/bin/php5.6 | |
echo 'echo "This script must be run as root, use sudo "$0" instead" 1>&2 ; exit 1 ;' >> /usr/local/bin/php5.6 | |
echo 'fi' >> /usr/local/bin/php5.6 | |
echo 'echo "Enable PHP5.6"' >> /usr/local/bin/php5.6 | |
echo 'a2dismod php7.0 > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'a2dismod php7.1 > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'a2enmod php5.6 > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'rm /usr/local/bin/phpunit > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'cp /usr/local/bin/phpunit-5 /usr/local/bin/phpunit > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'rm -r /etc/alternatives/phar' >> /usr/local/bin/php5.6 | |
echo 'rm -r /etc/alternatives/phar.1.gz' >> /usr/local/bin/php5.6 | |
echo 'rm -r /etc/alternatives/phar.phar' >> /usr/local/bin/php5.6 | |
echo 'rm -r /etc/alternatives/phar.phar.1.gz' >> /usr/local/bin/php5.6 | |
echo 'rm -r /etc/alternatives/php' >> /usr/local/bin/php5.6 | |
echo 'rm -r /etc/alternatives/php.1.gz' >> /usr/local/bin/php5.6 | |
echo 'rm -r /etc/alternatives/php-config' >> /usr/local/bin/php5.6 | |
echo 'rm -r /etc/alternatives/php-config.1.gz' >> /usr/local/bin/php5.6 | |
echo 'rm -r /etc/alternatives/phpsize' >> /usr/local/bin/php5.6 | |
echo 'rm -r /etc/alternatives/phpsize.1.gz' >> /usr/local/bin/php5.6 | |
echo 'ln -s /usr/bin/phar5.6 /etc/alternatives/phar > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'ln -s /usr/share/man/man1/phar5.6.1.gz /etc/alternatives/phar.1.gz > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'ln -s /usr/bin/phar.phar5.6 /etc/alternatives/phar.phar > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'ln -s /usr/share/man/man1/phar.phar5.6.1.gz /etc/alternatives/phar.phar.1.gz > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'ln -s /usr/bin/php5.6 /etc/alternatives/php > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'ln -s /usr/share/man/man1/php5.6.1.gz /etc/alternatives/php.1.gz > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'ln -s /usr/bin/php-config5.6 /etc/alternatives/php-config > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'ln -s /usr/share/man/man1/php-config5.6.1.gz /etc/alternatives/php-config.1.gz > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'ln -s /usr/bin/phpsize5.6 /etc/alternatives/phpsize > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'ln -s /usr/share/man/man1/phpsize5.6.1.gz /etc/alternatives/phpsize.1.gz > /dev/null' >> /usr/local/bin/php5.6 | |
echo 'service apache2 restart > /dev/null' >> /usr/local/bin/php5.6 | |
chmod ugo+x /usr/local/bin/php5.6 > /dev/null | |
echo 'Add script for switching to PHP7.0' | |
echo '#!/bin/bash' > /usr/local/bin/php7.0 | |
echo 'if [[ $EUID -ne 0 ]]; then' >> /usr/local/bin/php7.0 | |
echo 'echo "This script must be run as root, use sudo "$0" instead" 1>&2 ; exit 1 ;' >> /usr/local/bin/php7.0 | |
echo 'fi' >> /usr/local/bin/php7.0 | |
echo 'echo "Enable PHP7.0"' >> /usr/local/bin/php7.0 | |
echo 'a2dismod php5.6 > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'a2dismod php7.1 > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'a2enmod php7.0 > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'rm /usr/local/bin/phpunit > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'cp /usr/local/bin/phpunit-6 /usr/local/bin/phpunit > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'rm -r /etc/alternatives/phar' >> /usr/local/bin/php7.0 | |
echo 'rm -r /etc/alternatives/phar.1.gz' >> /usr/local/bin/php7.0 | |
echo 'rm -r /etc/alternatives/phar.phar' >> /usr/local/bin/php7.0 | |
echo 'rm -r /etc/alternatives/phar.phar.1.gz' >> /usr/local/bin/php7.0 | |
echo 'rm -r /etc/alternatives/php' >> /usr/local/bin/php7.0 | |
echo 'rm -r /etc/alternatives/php.1.gz' >> /usr/local/bin/php7.0 | |
echo 'rm -r /etc/alternatives/php-config' >> /usr/local/bin/php7.0 | |
echo 'rm -r /etc/alternatives/php-config.1.gz' >> /usr/local/bin/php7.0 | |
echo 'rm -r /etc/alternatives/phpsize' >> /usr/local/bin/php7.0 | |
echo 'rm -r /etc/alternatives/phpsize.1.gz' >> /usr/local/bin/php7.0 | |
echo 'ln -s /usr/bin/phar7.0 /etc/alternatives/phar > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'ln -s /usr/share/man/man1/phar7.0.1.gz /etc/alternatives/phar.1.gz > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'ln -s /usr/bin/phar.phar7.0 /etc/alternatives/phar.phar > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'ln -s /usr/share/man/man1/phar.phar7.0.1.gz /etc/alternatives/phar.phar.1.gz > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'ln -s /usr/bin/php7.0 /etc/alternatives/php > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'ln -s /usr/share/man/man1/php7.0.1.gz /etc/alternatives/php.1.gz > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'ln -s /usr/bin/php-config7.0 /etc/alternatives/php-config > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'ln -s /usr/share/man/man1/php-config7.0.1.gz /etc/alternatives/php-config.1.gz > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'ln -s /usr/bin/phpsize7.0 /etc/alternatives/phpsize > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'ln -s /usr/share/man/man1/phpsize7.0.1.gz /etc/alternatives/phpsize.1.gz > /dev/null' >> /usr/local/bin/php7.0 | |
echo 'service apache2 restart > /dev/null' >> /usr/local/bin/php7.0 | |
chmod ugo+x /usr/local/bin/php7.0 > /dev/null | |
echo 'Add script for switching to PHP7.1' | |
echo '#!/bin/bash' > /usr/local/bin/php7.1 | |
echo 'if [[ $EUID -ne 0 ]]; then' >> /usr/local/bin/php7.1 | |
echo 'echo "This script must be run as root, use sudo "$0" instead" 1>&2 ; exit 1 ;' >> /usr/local/bin/php7.1 | |
echo 'fi' >> /usr/local/bin/php7.1 | |
echo 'echo "Enable PHP7.1"' >> /usr/local/bin/php7.1 | |
echo 'a2dismod php5.6 > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'a2dismod php7.0 > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'a2enmod php7.1 > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'rm /usr/local/bin/phpunit > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'cp /usr/local/bin/phpunit-6 /usr/local/bin/phpunit > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'rm -r /etc/alternatives/phar' >> /usr/local/bin/php7.1 | |
echo 'rm -r /etc/alternatives/phar.1.gz' >> /usr/local/bin/php7.1 | |
echo 'rm -r /etc/alternatives/phar.phar' >> /usr/local/bin/php7.1 | |
echo 'rm -r /etc/alternatives/phar.phar.1.gz' >> /usr/local/bin/php7.1 | |
echo 'rm -r /etc/alternatives/php' >> /usr/local/bin/php7.1 | |
echo 'rm -r /etc/alternatives/php.1.gz' >> /usr/local/bin/php7.1 | |
echo 'rm -r /etc/alternatives/php-config' >> /usr/local/bin/php7.1 | |
echo 'rm -r /etc/alternatives/php-config.1.gz' >> /usr/local/bin/php7.1 | |
echo 'rm -r /etc/alternatives/phpsize' >> /usr/local/bin/php7.1 | |
echo 'rm -r /etc/alternatives/phpsize.1.gz' >> /usr/local/bin/php7.1 | |
echo 'ln -s /usr/bin/phar7.1 /etc/alternatives/phar > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'ln -s /usr/share/man/man1/phar7.1.1.gz /etc/alternatives/phar.1.gz > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'ln -s /usr/bin/phar.phar7.1 /etc/alternatives/phar.phar > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'ln -s /usr/share/man/man1/phar.phar7.1.1.gz /etc/alternatives/phar.phar.1.gz > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'ln -s /usr/bin/php7.1 /etc/alternatives/php > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'ln -s /usr/share/man/man1/php7.1.1.gz /etc/alternatives/php.1.gz > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'ln -s /usr/bin/php-config7.1 /etc/alternatives/php-config > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'ln -s /usr/share/man/man1/php-config7.1.1.gz /etc/alternatives/php-config.1.gz > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'ln -s /usr/bin/phpsize7.1 /etc/alternatives/phpsize > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'ln -s /usr/share/man/man1/phpsize7.1.1.gz /etc/alternatives/phpsize.1.gz > /dev/null' >> /usr/local/bin/php7.1 | |
echo 'service apache2 restart > /dev/null' >> /usr/local/bin/php7.1 | |
chmod ugo+x /usr/local/bin/php7.1 > /dev/null | |
php7.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not compatible for Rasbian, missing