正确配置nginx到localhost? [英] correct configuration for nginx to localhost?

查看:2843
本文介绍了正确配置nginx到localhost?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了nginx和php fastcgi大约一个小时前,在阅读一个快速启动配置的示例和nginx文档等,我只是不能得到它的工作。

I just installed nginx and php fastcgi about an hour ago, and after reading examples of a quick starting configuration, and the nginx documentation etc, I just cant get it to work.

无论我改变或尝试,我总是只得到欢迎来到Nginx!屏幕onlocalhost / ... - 我甚至不能调用一个简单的index.html

No matter what I change or try, I always only get the "Welcome to Nginx!" screen on "localhost/..." - I cant even call a simple index.html

我的配置:

(评论中的东西是我试过的)

(the stuff in the comments is what I tried out)

// default nginx stuff (unchanged)

server {
    #listen 80 default_server;
    #listen 80 default;
    listen 80;

    #server_name localhost;
    #server_name _;

    #access_log /var/log/nginx/board.access_log;
    #error_log /var/log/nginx/board.error_log;

    #root /var/www/board;
    #root /var/www/board/public/;
    root /var/www/board/public;

    #index index.html;
    index index.html index.htm index.php;
}



如果我理解正确,这应该是最简单的设置,对吗?只是定义 listen 80; index index.html; 但我只是不能得到它工作

If I understand it right, this should be the easiest setup, right? just define listen 80; and index index.html; but I just cant get it to work

文件/var/www/board/public/index.html已存在并具有内容

The file /var/www/board/public/index.html exists and has content

在我再浪费2个小时之前出来的东西,你有人可以给它一个快速的手表,告诉我我做错了什么?感谢。

Before I waste 2 more hours trying out something, can someone of you give it a quick watch and tell me what I'm doing wrong? Thanks.

推荐答案

从根本上你没有声明位置,这是nginx用来绑定资源的URL。

Fundamentally you hadn't declare location which is what nginx uses to bind URL with resources.

 server {
            listen       80;
            server_name  localhost;

            access_log  logs/localhost.access.log  main;

            location / {
                root /var/www/board/public;
                index index.html index.htm index.php;
            }
       }

这篇关于正确配置nginx到localhost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆