Last active
August 31, 2018 02:15
-
-
Save manraog/0b83c3e2b59f7f41a5b1a9d0939a452c to your computer and use it in GitHub Desktop.
Installs LAMP with PHP 5.6 on Ubuntu 16.04
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
sudo add-apt-repository ppa:ondrej/php | |
sudo apt-get update | |
sudo apt-get install -y apache2 | |
sudo ufw allow in "Apache Full" | |
sudo apt-get install -y mysql-server | |
# After running this command, select (Y), option 2, then (Y) for the rest of the prompts. | |
sudo mysql_secure_installation | |
sudo apt install -y php5.6 libapache2-mod-php5.6 php5.6-curl php5.6-gd php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-xmlrpc | |
# This will, and should, return a "does not exist!" message. | |
sudo a2dismod php7.0 | |
# This will, and should, return a "already enabled" message. | |
sudo a2enmod php5.6 | |
sudo systemctl restart apache2 | |
################################################################################## | |
# Once we have PHP 5.6 (or 5.5) and 7.0 installed, we can easily switch between them from the shell using these commands. To enable PHP 5.6 (and disable PHP 7.0) use this command: | |
sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart ; echo 1 | sudo update-alternatives --config php | |
# Similarly, to switch from PHP 5.6 to PHP 7.0, use this command: | |
sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart ; echo 2 | sudo update-alternatives --config php | |
# Or, better yet, why not set up a couple of simple Bash aliases in your .bashrc to take care of this for you: | |
alias phpv5='sudo a2dismod php7.0 ; sudo a2enmod php5.6 ; sudo service apache2 restart ; echo 1 | sudo update-alternatives --config php' | |
alias phpv7='sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart ; echo 2 | sudo update-alternatives --config php' | |
# Reference: https://phpraxis.wordpress.com/2016/05/16/install-php-5-6-or-5-5-in-ubuntu-16-04-lts-xenial-xerus/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment