-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathphp-update.sh
47 lines (34 loc) · 1.27 KB
/
php-update.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
#!/bin/bash
# ARE YOU ROOT (or sudo)?
if [[ $EUID -ne 0 ]]; then
echo -e "\e[91mERROR: This script must be run as root\e[0m"
exit 1
fi
centos_version=$(rpm -qa \*-release | grep -Ei "oracle|redhat|centos" | sed 's/[^6-8]*//g' | cut -c1)
#########################
# CentOS 6 installation #
#########################
if [ "$centos_version" -eq 6 ]; then
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-6.rpm
#########################
# CentOS 7 installation #
#########################
elif [ "$centos_version" -eq 7 ]; then
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm
#########################
# CentOS 8 installation #
#########################
else
exit 1
fi
# get the latest version remi-php file (ie. remi-php74.repo)
repofile=$(ls /etc/yum.repos.d/remi-php7*.repo -r | head -1) # error while upgrading to php 8.0
# change the enabled bit from 0 to 1 and enable the mirrorlist (only first occurrence)
sed -i "0,/enabled=0/s/enabled=0/enabled=1/" $repofile
sed -i "0,/#mirrorlist/s/#mirrorlist/mirrorlist/" $repofile
yum upgrade php -y
service php-fpm restart
service nginx restart
php -v