Explosion Pills
Explosion Pills

Reputation: 191819

*Actually* getting nginx to reload config

I'm trying to set up a subdomain with nginx on Ubuntu 13.04. I was actually able to do this before with:

server {
    root /home/ajcrites/projects/site-a/public/;
    server_name sub.localhost;

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

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}

Then http://sub.localhost would work perfectly.

Now, I've copied the same config and just changed root (to a path that exists) and server_name to some other value like subber.localhost. No matter what I do, I can't get subber.localhost to work. Also no matter what I do, I can't get sub.localhost to not work while nginx is running. What's weird is that nginx actually will complain about errors in the config files, but even if there are none it doesn't matter. Only sub.localhost will work.

I've tried doing all of the following, repeatedly and with various combinations:

When I stop it, pgrep does not show any nginx process, so it seems like it is correctly getting stopped. This does not appear to be a cache issue as a fresh browser instance reacts the same way.

Upvotes: 0

Views: 899

Answers (1)

Déjà vu
Déjà vu

Reputation: 28850

I happen to have had similar problems, each time that was a simple issue (that took me a long time to find though). For instance (sorry if some points are obvious - but sometimes we focus on the difficult, ignoring the obvious - at least that's my case)

  • ensure the symlink is present in sites-enabled
  • root path has read access all the way from / (at at least x) for the nginx user
  • is subber.localhost well defined in /etc/hosts for local tests (or local DNS),

Maybe you could try to force the IP on which listen is listening. Eg instead of

listen 80

you could try

listen 127.0.0.1:80;     # OR
listen 192.168.0.1:80;   # you local address (or remote if that's the case)

Upvotes: 2

Related Questions