Link to home
Start Free TrialLog in
Avatar of dmontgom
dmontgom

asked on

Ubuntu Lucid and Getting nginx to work

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;
   }
# }

Avatar of torimar
torimar
Flag of Germany image

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?
Avatar of dmontgom
dmontgom

ASKER

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.
Did you restart Nginx?

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

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.
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

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.

ASKER CERTIFIED SOLUTION
Avatar of torimar
torimar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial