Getting rid of "Welcome to nginx"

Hi guys,

I’ve just setup nginx on my Ubuntu staging machine. 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;
    }

}

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,213878,213878#msg-213878

Hi Joakim,

Your issue seems quite simple: You should use “try_files $uri $uri/
/index.php”, otherwise the .html version is shown.

Regards,
Mathias Teugels

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,213878,213883#msg-213883

Hi Mathias,

Thanks for your answer. That won’t do it unfortunately. Also tried
moving the “try_files” param out of the “location /” bracket - no luck
with that either.

What I did when setting up Nginx was following the instructions in the
/etc/nginx/sites-available/default config file. So I created my new file
containing the above config in “/etc/nginx/sites-available/local” and
made a symlink to it in “etc/nginx/sites-enabled”.

I then restarted Nginx. I’ve messed around with the settings in my
“local” file and seen PHP stopped working completely, so I know that
Nginx actually are loading my config, but just ignore to call my
index.php when the URL ends with / or /index.php…

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,213878,213884#msg-213884

On Wed, Aug 17, 2011 at 1:37 AM, Joakim [email protected] wrote:

Hi guys,

I’ve just setup nginx on my Ubuntu staging machine. 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:

have you tried clearing your browser’s cache?

Thanks Edho! That did it. I tried cleaning the cache when I first saw
the error, but as I tried different settings I forgot to clean again.
Never thought it were that simple :slight_smile:

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,213878,213914#msg-213914