Nginx – How does YUM know which repository to use for installation if the same application is available in two repos

nginxyum

EXAMPLE SCENARIO: Installing Nginx

I am installing Nginx. In order to get the latest repo, I download the RPM from the Nginx website. Like so:

rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

Since I need to install PHP-FPM, I also downloaded a couple more repos from somewhere else, like so:

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm


rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Now the first repo also contains Nginx. So when I type:

yum install nginx

Which repo will YUM use to install Nginx?

Thanks!

Best Answer

If the package name absolutely the same in both repos, yum will resolve this alphabetically.

Therefore it will download the rpm from repo which is first in the natural order. Usually in my experience though I would always install yum priorities plugin, which would help me to prioritize repos on user defined criterias. You can get more info here: http://wiki.centos.org/PackageManagement/Yum/Priorities

EDIT:

My accepted answer is not correct. If the package name is absolutely the same in both repos, yum will not resolve this alphabetically. Michael was correct. This is an official answer from redhat about this scenario:

So in this condition, yum will simply query the repositories and whichever gets the first fetch query, will reply back and the package with its dependencies will be fetched out from the same. There will not be any conflicts. The package downloaded will be random in nature.