简体   繁体   中英

Nginx default vhost config not working

Setting up nginx on an Ubuntu 12.04 LTS server. 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.

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

Many thanks.

(check your DNS too, you need to add the subdomain A entry there)

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; include 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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