nginx virtual hosts are not working, all vhosts goes to the default one
- by Adirael
Hello,
I just did a clean install of nginx + php-fpm on a VPS running Ubuntu 10.10, nginx is serving and PHP is working fine, but I'm not able to add vhosts to it. Well, I can add them, but only one works, the rest go to this first one.
This is my first vhost, for host1:
server {
listen 80;
server_name host1;
access_log /var/log/nginx/host1.log;
error_log /var/log/nginx/host1.error.log;
location / {
root /var/www/vhosts/host1/;
index index.html index.htm index.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME /var/www/vhosts/host1/$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_index index.php;
}
}
And the second one, for host2:
server {
listen 80;
server_name host2;
access_log /var/log/nginx/host2.log;
error_log /var/log/nginx/host2.error.log;
location / {
root /var/www/vhosts/host2/;
index index.html index.htm index.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME /var/www/vhosts/host2/$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_index index.php;
}
}
The problem is, when I go to http://host1 everything is fine, but on http://host2, it just shows host1!
I don't have Apache installed and everything comes from repos. Any pointers?