我的NGINX conf文件是否正确

时间:2015-03-29 10:00:39

标签: nginx centos

我是NGINX的新手,我无法判断我是否正确设置了conf文件。我正在尝试提供位于data / www目录中的index.html文件。我做了很多研究,但我似乎无法弄明白。我在运行ecOS 6.5的ec2上安装了nginx。任何关于如何启动和运行的指针都将非常感激。我一直试图绕过这一段时间。提前谢谢!

    user  nginx;
    worker_processes  1;

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


    events {
        worker_connections  1024;
    }


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

        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';

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

        sendfile        on;
        #tcp_nopush     on;

        keepalive_timeout  65;

        #gzip  on;

        server {
           listen 80;
           server_name <my elastic ip address>;

           location / {
             root /data/www/;
             index index.html;
           }
         }

    }

1 个答案:

答案 0 :(得分:0)

是, 您的配置文件是正确的。

注:

  • 工作:首先检查你的nginx服务器是否正在运行,在浏览器中键入你的ip:port(你在conf文件中给出)。如果运行它将显示nginx当前版本的详细信息。
  • 访问:您可以使用这样的命令访问您的文件。
  

http://your_ip_addr:port/application name / file_name

*应用程序名称:为该应用程序指定的名称, 例如

location /html {
    ......
   }

然后您的应用程序名称将变为html。