Skip to content

Instantly share code, notes, and snippets.

@heyost
Created March 17, 2017 03:45
Show Gist options
  • Save heyost/dbb2c062139058550e8fb2f4fd4ff135 to your computer and use it in GitHub Desktop.
Save heyost/dbb2c062139058550e8fb2f4fd4ff135 to your computer and use it in GitHub Desktop.
Simple script to change httpd/apache configuration file

First run this outside script sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.bak.conf

Make sure, you have 2 php version installed on computer, and create 2 configuration httpd/apache file to easy change php version

After script created, save on home and use bashrc to create alias e.g. alias switch-php=". ~/Script/switch_php.sh" put on last line, restart bash, and excute switch-php 7 to change php to version 7, and switch-php 56 to change to php version 56

#!/bin/bash
printf "Please wait...\n"
if [[ "$1" == 7 ]];
then
printf "Switching php to version 7.*\n"
sudo rm /etc/httpd/conf/httpd.conf
sudo mv /etc/httpd/conf/httpd7.conf /etc/httpd/conf/httpd.conf
sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd7.conf
sudo systemctl restart httpd # depending distributions used
else
printf "Switchign php to version 5.*\n"
sudo rm /etc/httpd/conf/httpd.conf
sudo mv /etc/httpd/conf/httpd56.conf /etc/httpd/conf/httpd.conf
sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd56.conf
sudo systemctl restart httpd # depending distributions used
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment