Solved

Ubuntu Lucid and Getting nginx to work

Posted on 2011-03-03
7
1,483 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create a textarea which saves text in HTML 8 46
Powercli + List all VM's Per SCSILUN 15 86
Dell Wyse 5030 zero client and dell monitors 5 41
PHP Curl to output a url 7 46
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

809 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