0

I have installed Nginx server on Ubuntu 11.04 system. The default directory is /usr/share/nginx/www, but I want that Nginx server will access the folders of http://localhost just like Apache web server.

So how to configure it?

My Nginx .conf file is like this

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

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

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

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


#mail {
#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#   # 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;
#   }
#}
Sathyajith Bhat
  • 286
  • 1
  • 5
  • 23
user159377
  • 101
  • 1

1 Answers1

1

Open the nginx.conf file and point the root to the Apache's DocumentRoot:

server {
        listen 127.0.0.1;
        server_name localhost;

        access_log /var/log/nginx/localhost.access_log main;
        error_log /var/log/nginx/localhost.error_log info;

        root /var/www;
    }
quanta
  • 50,327
  • 19
  • 152
  • 213
  • well my nginx.conf file is like this which I have edited now. – user159377 Sep 13 '11 at 16:25
  • Insert a `server` block as above into `http` block. – quanta Sep 13 '11 at 16:35
  • ya thanks that helped me out but when I used http://localhost it showed that nginx is running but the folder inside www root folder of localhost is showing 403 Forbidden. Now how to access the folder inside it. – user159377 Sep 13 '11 at 16:45
  • Take a look at error log, it will tell you more details. – quanta Sep 13 '11 at 16:49
  • If you are getting a 403, check your permisions on the folder. which in this case is, /var/www. If they were from apache they could be to www-data – J. M. Becker Sep 13 '11 at 18:00