Solved

Ubuntu Lucid and Getting nginx to work

Posted on 2011-03-03
7
1,479 Views
Last Modified: 2012-08-14
Hi,

I used the following to install nginx on ubunto.  

sudo apt-get install nginx python-flup

Tried to start the server but I get the following...


configuration file /etc/nginx/nginx.conf test is successful
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: still could not bind()
nginx.

I have apache installed so...how can I change the port in the conf file to isten to port 82  for example.  Below is the conf file.  ow should hte conf file look?


user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

http {
    include       /etc/nginx/mime.types;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    server {
        listen 8081 default;
        server_name localhost;
    }
}

# mail {
#     # See sample authentication script at:
#     # http://wiki.nginx.org/NginxImapAuthenticateWithApachePhpScript
#
#     # auth_http localhost/auth.php;
#     # pop3_capabilities "TOP" "USER";
#     # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#     server {
#         listen     localhost:110;
#         protocol   pop3;
#         proxy      on;
#     }
#
#     server {
#         listen     localhost:143;
#         protocol   imap;
#         proxy      on;

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

http {
    include       /etc/nginx/mime.types;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

# mail {
#     # See sample authentication script at:
#     # http://wiki.nginx.org/NginxImapAuthenticateWithApachePhpScript
#
#     # auth_http localhost/auth.php;
#     # pop3_capabilities "TOP" "USER";
#     # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#     server {
#         listen     localhost:110;
#         protocol   pop3;
#         proxy      on;
#     }
#
#     server {
#         listen     localhost:143;
#         protocol   imap;
#         proxy      on;
   }
# }

0
Comment
Question by:dmontgom
  • 4
  • 3
7 Comments
 
LVL 35

Expert Comment

by:torimar
ID: 35031336
Try this:

http {
    include       /etc/nginx/mime.types;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    server {
        listen 82;
        server_name localhost;
    }

Open in new window


More on this here: http://wiki.nginx.org/NginxHttpCoreModule#listen


ps:
This is an Ubuntu and Linux question; why is it not in those zones?
0
 

Author Comment

by:dmontgom
ID: 35031619
I still get this but added the code.

Starting nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: still could not bind()
nginx.
0
 
LVL 35

Expert Comment

by:torimar
ID: 35032069
Did you restart Nginx?

That needs to be done in order for the new configuration to be effective.

0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:dmontgom
ID: 35032484
Heres what happened

sudo /etc/init.d/nginx restart
Restarting nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: still could not bind()
nginx.
0
 
LVL 35

Expert Comment

by:torimar
ID: 35032654
Sorry, I apologize for my stupid question. It is more than obvious that you were trying to start.

I was actually planning to write a different post, but then I read your listing again and it was also obvious that Nginx does not reflect the conf file changes in its attempt to start. It still acts as though the conf file hadn't been changed.

This leaves only the following options, I presume:
1. your modifications of the files were not saved;
2. editing somehow corrupted the conf file's format, so that Nginx ignores it and tries to start with default settings;
3. you edited the wrong conf file.

Could you rule out all these options?
Are you sure you copied the modified listing which I posted to the correct location inside the file?
Also: check the file contents you posted above: it is doubled, has the same contents twice in a row. That certainly will not be correct, and the second "http {" module may overwrite the first one.

Try it with only this content:
user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

http {
    include       /etc/nginx/mime.types;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    server {
        listen 82;
        server_name localhost;
    }
}

# mail {
#     # See sample authentication script at:
#     # http://wiki.nginx.org/NginxImapAuthenticateWithApachePhpScript
#
#     # auth_http localhost/auth.php;
#     # pop3_capabilities "TOP" "USER";
#     # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#     server {
#         listen     localhost:110;
#         protocol   pop3;
#         proxy      on;
#     }
#
#     server {
#         listen     localhost:143;
#         protocol   imap;
#         proxy      on;
#     }
#}

Open in new window

0
 

Author Comment

by:dmontgom
ID: 35033708
Hmmmm

I stopped apache

THen started nginx.  It worked on 127.0.0.1

On /etc/init.d/apache2 start it said not found

On localhost:82 is said not found

I used your conf file.  Its the same one tat I had

When starting is says ....Restarting nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

I am using that file.  Yes...the modifications were saved.

0
 
LVL 35

Accepted Solution

by:
torimar earned 250 total points
ID: 35035679
This is odd.

I've been searching for quite a while, but now I think I found the reason: the default virtual host conf file needs to be modified as well. None of the Nginx install guides tell you, not even the one from Nginx themselves, only the fantastic guys over at Howtoforge.com do.

Open the file: /etc/nginx/sites-available/default
Make sure, the "server" container starts like this
server {
        listen   82;
        server_name  localhost;

Open in new window


Also make sure there is no "listen 80;" left in the file.

Now save and try starting Nginx again.

0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
razorCMS: Change Menu Font 4 49
Vsphere 5.5 -- VM Consolidation Issue 10 79
V2V Hyper-V RODC to ESXi 4 64
This code tracks birthdays 3 60
It Is not possible to enable LLDP in vSwitch(at least is not supported by VMware), so in this article we will enable this, and also go trough how to enabled CDP and how to get this information in vSwitches and also in vDS.
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now