-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpswitcher.sh
executable file
·73 lines (66 loc) · 1.87 KB
/
phpswitcher.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# This interactive script will create the directories required for php5.6 and php7.0
# in the virtual host directories. It is interactive so that you can choose to
# create the directories only in your virtual hosts
function ask() {
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
read -p "$1 [$prompt] " REPLY </dev/tty
if [ -z "$REPLY" ]; then
REPLY=$default
fi
case "$REPLY" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}
#Default to No if the user presses enter without giving an answer:
if ask "Do you want to do switch to PHP 7 version?" N; then
echo "Editing symoblic link"
filename = /usr/local/php5
if [ -L $filename ] ; then
rm /usr/local/php5
fi
ln -s /usr/local/php5-7.1.8-20170817-170852 php5
chown -h sukhjindersingh:staff /usr/local/php5
echo
echo "changing Apache httpd.conf file to point to php 7 version"
rm /etc/apache2/httpd.conf
cp /etc/apache2/httpd.conf.php7 /etc/apache2/httpd.conf
echo
echo "Resarting apache2 server"
echo
apachectl restart
else
if ask "Do you want to do switch to PHP 5.6 version?" N; then
echo "Editing symoblic link"
if [ -L $filename ] ; then
rm /usr/local/php5
fi
ln -s /usr/local/php5-5.6.9-20150515-130841 php5
chown -h sukhjindersingh:staff /usr/local/php5
echo
echo "changing Apache httpd.conf file to point to php 7 version"
rm /etc/apache2/httpd.conf
cp /etc/apache2/httpd.conf.php5 /etc/apache2/httpd.conf
echo
echo "Resarting apache2 server"
echo
apachectl restart
fi
fi
echo
php --version
echo
echo "Process complete... exiting"
echo