Issue with Virtual Hosting with FastCGI

Cliff Wells cliff at develix.com
Tue Jun 17 01:21:03 MSD 2008


On Mon, 2008-06-16 at 16:50 -0400, nginx at fuse969.com wrote:
> I've been trying to setup virtual hosting for few blog sites using the
> wordpress clean urls and fastcgi. The 1st vhost comes up but when i call
> the other address it goes to the 1st vhost so not sure if its syntax issue
> here's copy of my config.. If someone could point out where my syntax maybe
> incorrect.

You need to add "www" to your list of server names, eg:

server_name  hottestgirlsofmyspace.net www.hottestgirlsofmyspace.net;

or you can use the wildcard syntax if your version of Nginx is new
enough (don't recall when this was added):

server_name *.hottestgirlsofmyspace.net;

otherwise when a request for an unmatched domain comes in, it defaults
to the first vhost.

Also, unless you have 8 cores on this box, having 8 worker processes
probably doesn't buy you anything, especially since you are forwarding
all the requests to the same PHP handler on port 9999.  You'd do much
better with one nginx worker and 8 PHP processes.

Regards,
Cliff

> user  nobody;
> worker_processes  8;
> 
> #error_log  logs/error.log;
> #error_log  logs/error.log  notice;
> #error_log  logs/error.log  info;
> 
> pid        logs/nginx.pid;
> 
> 
> events {
>     worker_connections  1024;
> }
> 
> 
> http {
>     include       conf/mime.types;
>     default_type  application/octet-stream;
> 
>     #log_format  main  '$remote_addr - $remote_user [$time_local] $request
> '
>     #                  '"$status" $body_bytes_sent "$http_referer" '
>     #                  '"$http_user_agent" "$http_x_forwarded_for"';
> 
>     #access_log  logs/access.log  main;
> 
>     sendfile        on;
>     tcp_nopush     on;
>    server_names_hash_bucket_size 128;
>     #keepalive_timeout  0;
>     keepalive_timeout  15;
> 
>     gzip  on;
> 
>     server {
>         listen       80;
>         server_name  hottestgirlsofmyspace.net;
>         location / {
>             root   /home/brocklanders/hottestgirlsofmyspace.net;
>             index  index.php;
>           
>    if (!-e $request_filename) {
>       rewrite  ^(.*)$  /index.php?q=$1  last;
>       break;
>     }  
>       location ~ .php$ {
>        fastcgi_pass  localhost:9999;
>        fastcgi_index index.php;
>        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>        fastcgi_param REQUEST_URI $request_uri;
>        fastcgi_param DOCUMENT_URI $document_uri;
>        fastcgi_param DOCUMENT_ROOT $document_root;
>        fastcgi_param REMOTE_ADDR $remote_addr;
>        fastcgi_param REMOTE_PORT $remote_port;
>        fastcgi_param SERVER_ADDR $server_addr;
>        fastcgi_param SERVER_PORT $server_port;
>        fastcgi_param SERVER_NAME $server_name;
>        fastcgi_param SCRIPT_FILENAME 
> /home/brocklanders/hottestgirlsofmyspace.net$fastcgi_script_name;
>        fastcgi_param QUERY_STRING $query_string;
>        fastcgi_param REQUEST_METHOD $request_method;
>        fastcgi_param CONTENT_TYPE $content_type;
>        fastcgi_param CONTENT_LENGTH $content_length;
>     }
> }
> }
> }
> server { 
>  listen  80;
>  server_name drunkestpartygirls.com;
>  location / {
>   root /home/brocklanders/drunkestpartygirls.com;
>   index index.php;
> if (!-e $request_filename) {
>       rewrite  ^(.*)$  /index.php?q=$1  last;
>       break;
>     }
>       location ~ .php$ {
>        fastcgi_pass  localhost:9999;
>        fastcgi_index index.php;
>        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>        fastcgi_param REQUEST_URI $request_uri;
>        fastcgi_param DOCUMENT_URI $document_uri;
>        fastcgi_param DOCUMENT_ROOT $document_root;
>        fastcgi_param REMOTE_ADDR $remote_addr;
>        fastcgi_param REMOTE_PORT $remote_port;
>        fastcgi_param SERVER_ADDR $server_addr;
>        fastcgi_param SERVER_PORT $server_port;
>        fastcgi_param SERVER_NAME $server_name;
>        fastcgi_param SCRIPT_FILENAME 
> /home/brocklanders/drunkestpartygirls.com$fastcgi_script_name;
>        fastcgi_param QUERY_STRING $query_string;
>        fastcgi_param REQUEST_METHOD $request_method;
>        fastcgi_param CONTENT_TYPE $content_type;
>        fastcgi_param CONTENT_LENGTH $content_length;
>     }
> }
> }
> }
> server {
>  listen  80;
>  server_name hottestgirlsofspringbreak.com;
>  location / {
>   root /home/brocklanders/hottestgirlsofspringbreak.com;
>   index index.php;
> if (!-e $request_filename) {
>       rewrite  ^(.*)$  /index.php?q=$1  last;
>       break;
>     }
>       location ~ .php$ {
>        fastcgi_pass  localhost:9999;
>        fastcgi_index index.php;
>        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>        fastcgi_param REQUEST_URI $request_uri;
>        fastcgi_param DOCUMENT_URI $document_uri;
>        fastcgi_param DOCUMENT_ROOT $document_root;
>        fastcgi_param REMOTE_ADDR $remote_addr;
>        fastcgi_param REMOTE_PORT $remote_port;
>        fastcgi_param SERVER_ADDR $server_addr;
>        fastcgi_param SERVER_PORT $server_port;
>        fastcgi_param SERVER_NAME $server_name;
>        fastcgi_param SCRIPT_FILENAME 
> /home/brocklanders/hottestgirlsofspringbreak.com$fastcgi_script_name;
>        fastcgi_param QUERY_STRING $query_string;
>        fastcgi_param REQUEST_METHOD $request_method;
>        fastcgi_param CONTENT_TYPE $content_type;
>        fastcgi_param CONTENT_LENGTH $content_length;
>     }
> }
> }
> }
> server {
>  listen  80;
>  server_name weratevacations.com;
>  location / {
>   root /home/brocklanders/weratevacations.com;
>   index index.php;
> if (!-e $request_filename) {
>       rewrite  ^(.*)$  /index.php?q=$1  last;
>       break;
>     }
>       location ~ .php$ {
>        fastcgi_pass  localhost:9999;
>        fastcgi_index index.php;
>        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>        fastcgi_param REQUEST_URI $request_uri;
>        fastcgi_param DOCUMENT_URI $document_uri;
>        fastcgi_param DOCUMENT_ROOT $document_root;
>        fastcgi_param REMOTE_ADDR $remote_addr;
>        fastcgi_param REMOTE_PORT $remote_port;
>        fastcgi_param SERVER_ADDR $server_addr;
>        fastcgi_param SERVER_PORT $server_port;
>        fastcgi_param SERVER_NAME $server_name;
>        fastcgi_param SCRIPT_FILENAME 
> /home/brocklanders/weratevacations.com$fastcgi_script_name;
>        fastcgi_param QUERY_STRING $query_string;
>        fastcgi_param REQUEST_METHOD $request_method;
>        fastcgi_param CONTENT_TYPE $content_type;
>        fastcgi_param CONTENT_LENGTH $content_length;
>     }
> }
> }
> }
> server {
>  listen  80;
>  server_name hottestflickrgirls.com;
>  location / {
>   root /home/brocklanders/hottestflickrgirls.com;
>   index index.php;
> if (!-e $request_filename) {
>       rewrite  ^(.*)$  /index.php?q=$1  last;
>       break;
>     }
>       location ~ .php$ {
>        fastcgi_pass  localhost:9999;
>        fastcgi_index index.php;
>        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>        fastcgi_param REQUEST_URI $request_uri;
>        fastcgi_param DOCUMENT_URI $document_uri;
>        fastcgi_param DOCUMENT_ROOT $document_root;
>        fastcgi_param REMOTE_ADDR $remote_addr;
>        fastcgi_param REMOTE_PORT $remote_port;
>        fastcgi_param SERVER_ADDR $server_addr;
>        fastcgi_param SERVER_PORT $server_port;
>        fastcgi_param SERVER_NAME $server_name;
>        fastcgi_param SCRIPT_FILENAME 
> /home/brocklanders/hottestflickrgirls.com$fastcgi_script_name;
>        fastcgi_param QUERY_STRING $query_string;
>        fastcgi_param REQUEST_METHOD $request_method;
>        fastcgi_param CONTENT_TYPE $content_type;
>        fastcgi_param CONTENT_LENGTH $content_length;
>     }
> }
> }
> }
> server {
>  listen  80;
>  server_name hottestgirlsofnightclubs.com;
>  location / {
>   root /home/brocklanders/hottestgirlsofnightclubs.com;
>   index index.php;
> if (!-e $request_filename) {
>       rewrite  ^(.*)$  /index.php?q=$1  last;
>       break;
>     }
>       location ~ .php$ {
>        fastcgi_pass  localhost:9999;
>        fastcgi_index index.php;
>        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>        fastcgi_param REQUEST_URI $request_uri;
>        fastcgi_param DOCUMENT_URI $document_uri;
>        fastcgi_param DOCUMENT_ROOT $document_root;
>        fastcgi_param REMOTE_ADDR $remote_addr;
>        fastcgi_param REMOTE_PORT $remote_port;
>        fastcgi_param SERVER_ADDR $server_addr;
>        fastcgi_param SERVER_PORT $server_port;
>        fastcgi_param SERVER_NAME $server_name;
>        fastcgi_param SCRIPT_FILENAME 
> /home/brocklanders/hottestgirlsofnightclubs.com$fastcgi_script_name;
>        fastcgi_param QUERY_STRING $query_string;
>        fastcgi_param REQUEST_METHOD $request_method;
>        fastcgi_param CONTENT_TYPE $content_type;
>        fastcgi_param CONTENT_LENGTH $content_length;
>     }
> }
> }
> }
> server {
>  listen  80;
>  server_name sexualaddictionresources.com;
>  location / {
>   root /home/brocklanders/sexualaddictionresources.com;
>   index index.php;
> if (!-e $request_filename) {
>       rewrite  ^(.*)$  /index.php?q=$1  last;
>       break;
>     }
>       location ~ .php$ {
>        fastcgi_pass  localhost:9999;
>        fastcgi_index index.php;
>        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>        fastcgi_param REQUEST_URI $request_uri;
>        fastcgi_param DOCUMENT_URI $document_uri;
>        fastcgi_param DOCUMENT_ROOT $document_root;
>        fastcgi_param REMOTE_ADDR $remote_addr;
>        fastcgi_param REMOTE_PORT $remote_port;
>        fastcgi_param SERVER_ADDR $server_addr;
>        fastcgi_param SERVER_PORT $server_port;
>        fastcgi_param SERVER_NAME $server_name;
>        fastcgi_param SCRIPT_FILENAME 
> /home/brocklanders/sexualaddictionresources.com$fastcgi_script_name;
>        fastcgi_param QUERY_STRING $query_string;
>        fastcgi_param REQUEST_METHOD $request_method;
>        fastcgi_param CONTENT_TYPE $content_type;
>        fastcgi_param CONTENT_LENGTH $content_length;
>     }
> }
> }
> }
> server {
>  listen  80;
>  server_name hottestgirlsofcheerleading.com;
>  location / {
>   root /home/brocklanders/hottestgirlsofcheerleading.com;
>   index index.php;
> if (!-e $request_filename) {
>       rewrite  ^(.*)$  /index.php?q=$1  last;
>       break;
>     }
>       location ~ .php$ {
>        fastcgi_pass  localhost:9999;
>        fastcgi_index index.php;
>        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>        fastcgi_param REQUEST_URI $request_uri;
>        fastcgi_param DOCUMENT_URI $document_uri;
>        fastcgi_param DOCUMENT_ROOT $document_root;
>        fastcgi_param REMOTE_ADDR $remote_addr;
>        fastcgi_param REMOTE_PORT $remote_port;
>        fastcgi_param SERVER_ADDR $server_addr;
>        fastcgi_param SERVER_PORT $server_port;
>        fastcgi_param SERVER_NAME $server_name;
>        fastcgi_param SCRIPT_FILENAME 
> /home/brocklanders/hottestgirlsofcheerleading.com$fastcgi_script_name;
>        fastcgi_param QUERY_STRING $query_string;
>        fastcgi_param REQUEST_METHOD $request_method;
>        fastcgi_param CONTENT_TYPE $content_type;
>        fastcgi_param CONTENT_LENGTH $content_length;
>     }
> }
> }
> }
> 
> server {
>  listen  80;
>  server_name hottestgirlsofsororities.com;
>  location / {
>   root /home/brocklanders/hottestgirlsofsororities.com;
>   index index.php;
> if (!-e $request_filename) {
>       rewrite  ^(.*)$  /index.php?q=$1  last;
>       break;
>     }
>       location ~ .php$ {
>        fastcgi_pass  localhost:9999;
>        fastcgi_index index.php;
>        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>        fastcgi_param REQUEST_URI $request_uri;
>        fastcgi_param DOCUMENT_URI $document_uri;
>        fastcgi_param DOCUMENT_ROOT $document_root;
>        fastcgi_param REMOTE_ADDR $remote_addr;
>        fastcgi_param REMOTE_PORT $remote_port;
>        fastcgi_param SERVER_ADDR $server_addr;
>        fastcgi_param SERVER_PORT $server_port;
>        fastcgi_param SERVER_NAME $server_name;
>        fastcgi_param SCRIPT_FILENAME 
> /home/brocklanders/hottestgirlsofsororities.com$fastcgi_script_name;
>        fastcgi_param QUERY_STRING $query_string;
>        fastcgi_param REQUEST_METHOD $request_method;
>        fastcgi_param CONTENT_TYPE $content_type;
>        fastcgi_param CONTENT_LENGTH $content_length;
>     }
> }
> }
> }
> server {
>  listen  80;
>  server_name uncoached.com;
>  location / {
>   root /home/brocklanders/uncoached.com;
>   index index.php;
> if (!-e $request_filename) {
>       rewrite  ^(.*)$  /index.php?q=$1  last;
>       break;
>     }
>       location ~ .php$ {
>        fastcgi_pass  localhost:9999;
>        fastcgi_index index.php;
>        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>        fastcgi_param REQUEST_URI $request_uri;
>        fastcgi_param DOCUMENT_URI $document_uri;
>        fastcgi_param DOCUMENT_ROOT $document_root;
>        fastcgi_param REMOTE_ADDR $remote_addr;
>        fastcgi_param REMOTE_PORT $remote_port;
>        fastcgi_param SERVER_ADDR $server_addr;
>        fastcgi_param SERVER_PORT $server_port;
>        fastcgi_param SERVER_NAME $server_name;
>        fastcgi_param SCRIPT_FILENAME 
> /home/brocklanders/uncoached.com$fastcgi_script_name;
>        fastcgi_param QUERY_STRING $query_string;
>        fastcgi_param REQUEST_METHOD $request_method;
>        fastcgi_param CONTENT_TYPE $content_type;
>        fastcgi_param CONTENT_LENGTH $content_length;
>     }
> }
> }
> }
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> }  
> 
> 






More information about the nginx mailing list