Nginx默认vhost配置不起作用

时间:2013-05-06 20:44:20

标签: nginx php

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

这是我的档案:

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

非常感谢。

1 个答案:

答案 0 :(得分:0)

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

listen   80;

应该是:

listen   your_full_ip;  // xxx.xxx.xx.xx (dont need to add the port if is the port 80)

这些:

location ~ .+\.php$ {

进入这些:

location ~ \.php$ {

将这两行移动到服务器块:  fastcgi_index index.php;  包括fastcgi_params;

按顺序放置服务器块:

server_name beta.davidheward.com;
listen   your_full_ip;
index index.php index.html index.htm;
root /usr/share/nginx/www;
希望它有所帮助。完成后重新启动nginx!

相关问题