Welcome! Log In Create A New Profile

Advanced

Trying to get multiple server blocks working

Posted by compunuts 
Trying to get multiple server blocks working
August 07, 2013 07:46AM
I'm working on CentOS 6.4, Nginx 1.0.15 with php and mysql.

I have two hosts I have in mind, www.domain1.com and sub.domain1.com. The default server had been set to localhost and it works just fine. The " include /etc/nginx/conf.d/*.conf; " had been uncommented in "/etc/nginx/nginx.conf" as well.


So I created two files inside "/etc/nginx/conf.d" folder

[code]
[compunuts@f150 conf.d]$ pwd
/etc/nginx/conf.d
[compunuts@f150 conf.d]$ ls
default.conf domain1.conf sub-domain1.conf
[compunuts@f150 conf.d]$
[/code]

Inside each file has config like this.

domain1.conf
[code]
server {
listen 80;
server_name www.domain1.com;
root /usr/local/ngnix/html/domain1;
index index.php index.html index.htm;
error_log /var/log/nginx/domain1/error.log;
access_log /var/log/nginx/domain1/access.log main;

location ~ \.php$ {
root /usr/local/nginx/html/domain1;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_$
include fastcgi_params;
}
location / {
try_files $uri $uri/ /index.php;
}
}
[/code]

sub-domain1.conf
[code]
server {
listen 80;
server_name sub.domain1.com;
root /usr/local/ngnix/html/sub-domain1;
index index.php index.html index.htm;
error_log /var/log/nginx/sub-domain1/error.log;
access_log /var/log/nginx/sub-domain1/access.log main;

location ~ \.php$ {
root /usr/local/nginx/html/sub-domain1;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_$
include fastcgi_params;
}
location / {
try_files $uri $uri/ /index.php;
}
}
[/code]

I have index.html file and info.php file inside both root directories. But when I put the url in the browser, it got "500 Internal Server Error" message. If I type localhost, it rendered to default page.

What am I doing wrong here? I read " http://wiki.nginx.org/ServerBlockExample " page and it says to put those in but didn't mention which file to put it in. Should I be putting in inside nginx.conf file?

Any pointer is highly appreciated. Thanks.
Re: Trying to get multiple server blocks working
August 07, 2013 07:36PM
Okay, I feel like an idiot right now ... and I can't blame on lack of sleep either ....

The problem was with root setting where I have the wrong spelling, nginx with ngnix .... Garrrrrrr ... two days of misery on simple stuff ....

:mad:
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 247
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready