3

I've just setup nginx on my Ubuntu staging machince. Entering http://192.168.1.1./index.php works like a charm and loads the index.php file i've put in the /var/www/public_html folder. http://192.168.1.1 however instead shows the Welcome to nginx! page and not my index.php file.

What am I doing wrong? Here's my nginx config:

server {

    listen 80 default;
    root /var/www/public_html;
    index index.php index.html index.htm;
    server_name _;

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

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}
Industrial
  • 1,579
  • 6
  • 24
  • 37

3 Answers3

1

I'm guessing that you still have the default site config in sites-enabled, and that it's alphabetically sorted higher than your custom config. The default config will catch any request without known host headers, and use index.html as index.

pauska
  • 19,620
  • 5
  • 57
  • 75
0

I had that same problem. It was solved when I changed the folder permissions of the index.html file.

0

Looking at the documentation for try_files: http://wiki.nginx.org/HttpCoreModule#try_files, you probably should have something like:

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

Take a look at the examples for Drupal, Wordpress, FastCGI, etc.

cjc
  • 24,916
  • 3
  • 51
  • 70