Nginx Linux packages for CentOS

This instructions is for centos,I always use CentOS,which is convenient for me who is green hand.So wish you enjoy it.
System Operation:CentOS,Almalinux,Rockylinux.etc.

Installation instructions

Before you install nginx for the first time on a new machine, you need to set up the nginx packages repository. Afterward, you can install and update nginx from the repository.

Remove old Nginx

yum remove nginx -y

Installation

Install the prerequisites

yum install yum-utils -y

To set up the yum repository, create the file named /etc/yum.repos.d/nginx.repo with the following contents

vi /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

To install nginx, run the following command

yum install nginx -y

By default, the repository for stable nginx packages is used. If you would like to use mainline nginx packages, run the following command

yum-config-manager --enable nginx-mainline

I suggest to use stable nginx not mainline nginx for few problems

Leave a Reply

Your email address will not be published. Required fields are marked *