首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nginx默认vhost配置不起作用

问Nginx默认vhost配置不起作用
EN

Stack Overflow用户
提问于 2013-05-07 04:44:20
回答 1查看 1.1K关注 0票数 0

在Ubuntu 12.04 LTS服务器上设置nginx。除了这个配置文件之外,所有这些都不允许我访问www/下的文件,就像我应该能够访问的那样。

这是我的文件:

代码语言:javascript
复制
server {
    listen   80;


    root /usr/share/nginx/www;
    index index.php index.html index.htm;

    server_name beta.davidheward.com;

    location / {
            try_files $uri $uri/ /index.html;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
          root /usr/share/nginx/www;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ .+\.php$ {
            #fastcgi_pass 127.0.0.1:9000;
            # With php5-fpm:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }

}

任何为什么会这样的想法都将受到极大的赞赏。我正在尝试访问beta.davidheward.com/info.php

非常感谢。

EN

回答 1

Stack Overflow用户

发布于 2013-05-07 06:12:54

(也检查你的域名,你需要在那里添加子域名A entry )

代码语言:javascript
复制
listen   80;

应该是:

代码语言:javascript
复制
listen   your_full_ip;  // xxx.xxx.xx.xx (dont need to add the port if is the port 80)

这些是:

代码语言:javascript
复制
location ~ .+\.php$ {

转换为以下内容:

代码语言:javascript
复制
location ~ \.php$ {

将以下两行移动到服务器块: fastcgi_index index.php;include fastcgi_params;

将服务器块按顺序排列:

代码语言:javascript
复制
server_name beta.davidheward.com;
listen   your_full_ip;
index index.php index.html index.htm;
root /usr/share/nginx/www;

希望能有所帮助。完成后执行nginx重启!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16406974

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档