15

I'm trying to install nginx on CentOS 6.5, then I added these lines on file /etc/yum.repos.d/nginx.repo enter image description here

Then install nginx by:
enter image description here

And I've got a message error: No package nginx available How can I fix it? I would greatly appreciate any help you can give me in working this problem!

Thơ Hoàng
  • 185
  • 1
  • 1
  • 8

10 Answers10

40

nginx is not a part of base CentOS repository.

But you can install EPEL repositiry to get nginx:

yum install epel-release

and then

yum install nginx

gexly
  • 501
  • 4
  • 5
15

This should work well for oraclelinux7

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install nginx

Dockerfile to install nginx on oraclelinux:

FROM oraclelinux:7-slim
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum -y install nginx && yum clean all && rm -rf /var/cache/yum
EXPOSE 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]
Mic
  • 345
  • 1
  • 3
  • 9
11

What worked for me (CentOS 7.1) was removing epel first:

yum remove epel-release
yum install epel-release
yum update
yum install nginx
Marc
  • 13,011
  • 11
  • 78
  • 98
10

Your repo url is having an error. It is necessary to manually replace $releasever with either "5" (for 5.x) or "6" (for 6.x), depending upon your OS version. Similarly you have to edit the $basearch also. After that do the following command

yum clean all

yum install nginx

An alternative option is to install the epel repository and install nginx from there.

yum install epel-release

yum clean all

yum install nginx

Amal G Jose
  • 2,486
  • 1
  • 20
  • 35
1

Install nginx first! Run the following commands to first add the EPEL repository (Extra Packages for Enterprise Linux) and then install nginx.

yum install epel-release
yum install nginx
André Laszlo
  • 15,169
  • 3
  • 63
  • 81
1

Try to disable plugins for yum:

vim /etc/yum.conf

set plugins=0, and re-install epel-release:

yum remove epel-release
yum install epel-release
yum install nginx

this works for me, good luck!

LI ZHE
  • 39
  • 2
1

Check if it is excluded from the yum source:

  1. Use vi /etc/yum.conf
  2. Check the exclude option
James Risner
  • 5,451
  • 11
  • 25
  • 47
Dalton
  • 11
  • 2
0

Although the otherwise-posted advice regarding manually setting the $releasever and $basearch values in the repo file will not hurt per se (at least while you stick to the software release referred to by the values you set), it is not strictly necessary.

I also have the exact contents you have posted, in a file named /etc/yum.repos.d/nginx.repo which functions correctly without having set the above values explicitly.

My advice would be to perform a yum updateprior to attempting to install (as it's possible that when you tried to install, yum had not queried all of the repo URLs from the files in /etc/yum.repos.d/ for the latest versions of their databases). Also make absolutely sure that your created file ends in .repo as otherwise it will be ignored by yum.

Failing that, check the SElinux security contexts on the files in that directory - or just go ahead and manually restore them by running restorecon -Rv '/etc/yum.repos.d' and check the file permissions on the manually created repo file(s), which should be owned by root:root and have show 644 as file permissions. To manually amend these, run chmod 644 /etc/yum.repos.d/nginx.repoand chown root:root /etc/yum.repos.d/nginx.repo

I hope that some part of the above resolves your issues!

BE77Y
  • 737
  • 6
  • 8
0

Check yum.conf file and it's exclude key

In addition to all above answers, Make sure nginx, httpd or any other package you want to install is not in the exclude list of yum.conf file.

  1. Open yum.conf file located at /etc/yum.conf

  2. Check the exclude key and remove nginx* if it's there

  3. Then try to install your package. in this case nginx:

    sudo yum install nginx

Pars
  • 4,932
  • 10
  • 50
  • 88
0

My problem was this line in /etc/yum.conf file:

exclude=apache* nginx* httpd* mod_* mysql* MySQL* mariadb* da_* *ftpd exim* sendmail* php* bind-chroot* dovecot*

I deleted nginx* and tried to install nginx:
yum install nginx

Ali Shefaee
  • 327
  • 3
  • 12