【问题标题】:configuring nginx server to store the static images and html配置 nginx 服务器来存储静态图片和 html
【发布时间】:2014-01-31 19:21:21
【问题描述】:

我想在我的 windows7 PC 上配置 nginx 服务器。用于存储图像和 html 文件。 我遵循了以下步骤: 1.我下载了nginx-1.2.9并解压到c:\文件中。 2. 创建了一个文件夹“data”,在“data”文件夹中创建了另外两个文件夹,分别是“WWW”和“images”。 3. 将所有图像保存在“images”文件夹中。和 .html 文件在文件夹“WWW”中。 4.现在使用命令C:\nginx-1.2.9>start nginx

启动nginx服务器
5.Made changes in nginx.conf file.`    
    #server {
    #location / {
    #    proxy_pass http://127.0.0.0:8080;
    #}

    #location /images/ {
    #    root /C:/data/images;
    # }


}

无法访问图像和 html 页面。 请帮我解决这个问题。我确定只在配置文件中出错.. 提前致谢, 萨提亚

【问题讨论】:

    标签: nginx


    【解决方案1】:

    您已经注释了配置数据。首先从您的配置文件中删除所有#。然后在服务器中使用以下代码{}

        location / {
        root data/www;
    }
    
    location /images/ {
        root data;
    }
    

    注意-nginx根文件夹中静态文件的位置应该是(根+位置)数据,文件的访问应该是“位置”数据。例如,在第一个位置配置中,静态文件应该出现在文件夹“data/WWW/”中,而在第二个位置配置中,静态文件应该出现在文件夹“data/images/”中。

    URL                               folder inside nginx home path
    -----                            --------------------------
    localhost/hello.html              data/WWW/hello.html
    localhost/images/img1.png         data/images/img1.png
    

    【讨论】:

      猜你喜欢
      • 2018-02-03
      • 1970-01-01
      • 2023-01-20
      • 2015-05-08
      • 2020-05-18
      • 2015-06-06
      • 2018-11-25
      • 2017-05-12
      • 2019-08-07
      相关资源
      最近更新 更多