简体   繁体   English

Nginx默认虚拟主机配置不起作用

[英]Nginx default vhost config not working

Setting up nginx on an Ubuntu 12.04 LTS server. 在Ubuntu 12.04 LTS服务器上设置nginx。 All gone swimmingly apart from this config file does not allow me to access files under the www/ with the domain like I should be able to. 除了这个配置文件之外,所有其他方面都让我无法访问www /下的文件,而我应该能够访问该域。

Here's my file: 这是我的档案:

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;
    }

} }

Any ideas why this would be would be massively appreciated. 任何想法,为什么会这样,将不胜感激。 I am trying to hit beta.davidheward.com/info.php 我正在尝试打beta.davidheward.com/info.php

Many thanks. 非常感谢。

(check your DNS too, you need to add the subdomain A entry there) (也检查您的DNS,您需要在其中添加子域A entry

listen   80;

should be: 应该:

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

these: 这些:

location ~ .+\.php$ {

into these: 这些:

location ~ \.php$ {

move these 2 lines to the server block: fastcgi_index index.php; 将这两行移至服务器块:fastcgi_index index.php; include fastcgi_params; 包括fastcgi_params;

put the server block in order: 按顺序排列服务器块:

server_name beta.davidheward.com;
listen   your_full_ip;
index index.php index.html index.htm;
root /usr/share/nginx/www;

hope it helps. 希望能帮助到你。 Do a nginx restart when u are done! 完成u后,重新启动nginx!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM