-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathinstall-nginx.sh
More file actions
61 lines (52 loc) · 1.52 KB
/
install-nginx.sh
File metadata and controls
61 lines (52 loc) · 1.52 KB
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
#!/bin/bash
# Works with Centos 8 and AWS LINUX 2
# Official documentation how to install
# https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#installing-a-prebuilt-centos-rhel-package-from-the-official-nginx-repository
echo "Install Nginx"
LINUX_VERSION=$(cat /etc/system-release)
echo $LINUX_VERSION
sudo yum remove nginx* -y
if echo $LINUX_VERSION | grep -q "Amazon Linux release 2"
then
echo "Install Uing Amazon Linux Extras"
OSRELEASE="7"
sudo amazon-linux-extras install nginx1 -y
sudo systemctl enable nginx
elif echo $LINUX_VERSION | grep -q "CentOS Linux release 8"
then
echo "Install Uing Centos 8"
OSRELEASE="8"
cat > /etc/yum.repos.d/nginx.repo <<END
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/\$releasever/\$basearch/
gpgcheck=0
enabled=1
module_hotfixes=true
END
sudo yum -y install nginx
elif echo $LINUX_VERSION | grep -q "Oracle Linux Server release 8"
then
echo "Oracle Linux Server release 8"
OSRELEASE="8"
cat > /etc/yum.repos.d/nginx.repo <<END
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/\$releasever/\$basearch/
gpgcheck=0
enabled=1
module_hotfixes=true
END
sudo yum -y install nginx
# Disable firewall on Oracle instance
sudo systemctl disable firewalld
sudo service firewalld stop
else
echo "$LINUX_VERSION Linux is not supported"
exit 1
fi
service nginx start
systemctl enable nginx
sudo chmod -R 775 /var/log/nginx/
nginx -v
echo "Install finished"