Nginx
March 22, 2023
Автоматизация установки Nginx
Несколько простеньких bash скриптов для установки Nginx в разных ОС.
#!/bin/bash # Mainline version apt -y install curl gnupg2 ca-certificates lsb-release echo "deb http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" \ | sudo tee /etc/apt/sources.list.d/nginx.list echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \ | sudo tee /etc/apt/preferences.d/99nginx curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc apt update apt -y install nginx systemctl enable nginx --now systemctl status nginx
#!/bin/bash # Stable version apt -y install curl gnupg2 ca-certificates lsb-release echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \ | sudo tee /etc/apt/sources.list.d/nginx.list echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \ | sudo tee /etc/apt/preferences.d/99nginx curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc apt update apt -y install nginx systemctl enable nginx --now systemctl status nginx
#!/bin/bash apt -y install nginx-full systemctl enable nginx --now systemctl status nginx
#!/bin/bash # Mainline version yum -y install yum-utils touch /etc/yum.repos.d/nginx.repo printf "[nginx-stable] name=nginx stable repo " >> /etc/yum.repos.d/nginx.repo echo 'baseurl=http://nginx.org/packages/centos/$releasever/$basearch/' >> /etc/yum.repos.d/nginx.repo printf "gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true [nginx-mainline] name=nginx mainline repo " >> /etc/yum.repos.d/nginx.repo echo 'baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/' >> /etc/yum.repos.d/nginx.repo printf "gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true " >> /etc/yum.repos.d/nginx.repo yum-config-manager --enable nginx-mainline yum -y install nginx systemctl enable nginx --now firewall-cmd --permanent --add-port=80/tcp firewall-cmd --permanent --add-port=443/tcp firewall-cmd --reload systemctl status nginx
#!/bin/bash # Stable version yum -y install yum-utils touch /etc/yum.repos.d/nginx.repo printf "[nginx-stable] name=nginx stable repo " >> /etc/yum.repos.d/nginx.repo echo 'baseurl=http://nginx.org/packages/centos/$releasever/$basearch/' >> /etc/yum.repos.d/nginx.repo printf "gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true [nginx-mainline] name=nginx mainline repo " >> /etc/yum.repos.d/nginx.repo echo 'baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/' >> /etc/yum.repos.d/nginx.repo printf "gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true " >> /etc/yum.repos.d/nginx.repo yum -y install nginx systemctl enable nginx --now firewall-cmd --permanent --add-port=80/tcp firewall-cmd --permanent --add-port=443/tcp firewall-cmd --reload systemctl status nginx
#!/bin/bash # Mainline version apt -y install curl gnupg2 ca-certificates lsb-release echo "deb http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" \ | sudo tee /etc/apt/sources.list.d/nginx.list echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \ | sudo tee /etc/apt/preferences.d/99nginx curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc apt update apt -y install nginx systemctl enable nginx --now systemctl status nginx