Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Hi I am a newbie on nginx, I tried to set it up on my server (running Ubuntu 4), which already has apache running.

So after I apt-get install it, I tried to start nginx. Then I get the message like this:

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)

That makes sense as Apache is using port 80.

Then I tried to modify nginx.conf, I reference some articles, so I changed it like so:

   server {

        listen       8080;

        location / {
         proxy_pass  http://94.143.9.34:9500;
         proxy_set_header   Host             $host:8080;
         proxy_set_header   X-Real-IP        $remote_addr;
         proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
         proxy_set_header Via    "nginx";
        }

After saving this and try to start nginx again, I still get the same error as previously. I cannot really find a related post about this, could any good people shred some light?

I should post all the content in conf here:

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       81;

        location / {
         proxy_pass  http://94.143.9.34:9500;
         proxy_set_header   Host             $host:81;
         proxy_set_header   X-Real-IP        $remote_addr;
         proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
         proxy_set_header Via    "nginx";
        }


    }
}

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

Basically, I changed nothing except adding the server part.

share|improve this question
    
Is this your complete config? If not, please post the complete configuration. Are you sure no other process is listening on port 8080? –  Khaled May 31 '12 at 7:15
    
As Khaled requested, I post all the content in the conf file, –  Zhao Peng May 31 '12 at 7:20
    
Please, post the output of sudo netstat -lnp | grep 80. –  Khaled May 31 '12 at 7:21
    
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13731/apache2 –  Zhao Peng May 31 '12 at 7:23
add comment

2 Answers 2

It seems that you've left the default server configuration in the sites_enabled folder.

The file in question has a bunch of commented out lines, but not all are - the default configuration is tangled among them. I suggest you remove the whole file (or the first part if all your configurations are in the same file).

However, if you can't find it there, I suggest you do a search for 80. It's bound to be in the nginx configuration files somewhere.

share|improve this answer
add comment

I am using VMWare and had the same errors.

I removed my default config for the sites_enabled but also removed :

listen   [::]:80

...from my config files (previously needed for MacPorts). I'm not sure which port VMWare listens on but it didn't like 80!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.