【问题标题】:Is my NGINX conf file correct我的 NGINX conf 文件是否正确
【发布时间】:2015-06-02 09:09:17
【问题描述】:

我是 NGINX 的新手,我不知道我是否正确设置了我的 conf 文件。我正在尝试提供位于 data/www 目录中的 index.html 文件。我做了很多研究,我似乎无法弄清楚。我在运行 centOS 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;
           }
         }

    }

【问题讨论】:

    标签: nginx centos


    【解决方案1】:

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

    注意:

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

    http://your_ip_addr:port/applicationname/file_name

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

    location /html {
        ......
       }
    

    那么你的应用名称就会变成html。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-25
      • 2013-08-10
      • 2016-07-15
      • 2013-04-05
      • 2020-11-02
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      相关资源
      最近更新 更多