no package nginx available

June 26, 2013 9.1k views
Trying to install Nginx on my new droplet and I'm getting the following error: "no package nginx available". How can I fix this?
14 Answers
Assuming this is a CentOS 5 droplet, this question may help: http://stackoverflow.com/questions/12580894/no-package-found-error-when-installing-nginx-on-centos-5
Hello. It's a CentOS6 droplet. I'm getting error this now:

root@ny1 [~]# sudo /etc/init.d/nginx start
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[FAILED]
It looks like you already have a service listening on TCP port 80, so nginx is not able to listen on that port.
You probably have Apache already installed.

Try this

$ service httpd sttop
$ service nginx start

If that works, remove apache

$ yum remove httpd*

That'll fix it.
Thank you Gavin. I received the following, is this right?

root@ny1 [~]# service httpd stop
root@ny1 [~]# service nginx start
Starting nginx: [ OK ]
root@ny1 [~]# sudo /etc/init.d/nginx start
root@ny1 [~]# yum remove httpd
Loaded plugins: fastestmirror
Setting up Remove Process
No Match for argument: httpd
Loading mirror speeds from cached hostfile
* base: centos.mirror.constant.com
* extras: mirror.ash.fastserv.com
* updates: mirror.trouble-free.net
No Packages marked for removal
root@ny1 [~]# yum remove httpd*
Loaded plugins: fastestmirror
Setting up Remove Process
No Match for argument: httpd*
Loading mirror speeds from cached hostfile
* base: centos.mirror.constant.com
* extras: mirror.ash.fastserv.com
* updates: mirror.trouble-free.net
No Packages marked for removal
root@ny1 [~]#
Why delete Apache? Aren't they supposed to run together?
@Nestor: you can check if nginx is running by running the following command:

netstat -plutn

and looking for the port nginx should listen on.
Ah, the way I have it running is nginx only, sorry for the confusion. If you're using nginx as a cache, then yes, you need both running, but then you run apache on a different port from nginx you use nginx as the front end server, and apache to run anything scripted by passing it through nginx.

See: https://www.digitalocean.com/community/articles/how-to-configure-nginx-as-a-front-end-proxy-for-apache
looks like nginx isn't even running. i'm a little confused (and slow) :)

Last login: Wed Jun 26 16:39:57 2013 from xx.xxx.xxx.x
root@ny1 [~]# netstat -plutn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 20313/exim
tcp 0 0 127.0.0.1:783 0.0.0.0:* LISTEN 20361/spamd.pid --m
tcp 0 0 0.0.0.0:2095 0.0.0.0:* LISTEN 1685/cpsrvd (SSL) -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4142/httpd
tcp 0 0 0.0.0.0:2096 0.0.0.0:* LISTEN 1685/cpsrvd (SSL) -
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 20313/exim
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 1611/pure-ftpd (SER
tcp 0 0 xxx.xxx.xx.xxx:53 0.0.0.0:* LISTEN 1012/named
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1012/named
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1375/sshd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 20313/exim
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 1012/named
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 4142/httpd
tcp 0 0 0.0.0.0:2077 0.0.0.0:* LISTEN 24376/cpdavd - acce
tcp 0 0 0.0.0.0:2078 0.0.0.0:* LISTEN 24376/cpdavd - acce
tcp 0 0 0.0.0.0:2082 0.0.0.0:* LISTEN 1685/cpsrvd (SSL) -
tcp 0 0 0.0.0.0:2083 0.0.0.0:* LISTEN 1685/cpsrvd (SSL) -
tcp 0 0 0.0.0.0:2086 0.0.0.0:* LISTEN 1685/cpsrvd (SSL) -
tcp 0 0 0.0.0.0:2087 0.0.0.0:* LISTEN 1685/cpsrvd (SSL) -
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1504/mysqld
tcp 0 0 :::587 :::* LISTEN 20313/exim
tcp 0 0 :::465 :::* LISTEN 20313/exim
tcp 0 0 :::21 :::* LISTEN 1611/pure-ftpd (SER
tcp 0 0 :::22 :::* LISTEN 1375/sshd
tcp 0 0 :::25 :::* LISTEN 20313/exim
udp 0 0 xxx.xxx.xx.xxx:53 0.0.0.0:* 1012/named
udp 0 0 127.0.0.1:53 0.0.0.0:* 1012/named
root@ny1 [~]#
-> Gavin, you're giving wrong tips about CentOS
No, don't remove Apache: uncorrect, you can have problems with PHP & Co in the future

Correct:
$ service httpd stop
$ service nginx start

If you receive following response:
[ok]

Do that:
$ chkconfig httpd off
@Matteo that worked man. Thanks!

@everyone...thank you for your help.

...now all I have to do is learn to configure and I should be set for a little bit.
Have another answer? Share your knowledge.