Welcome! Log In Create A New Profile

Advanced

Nginx + php-fpm and multi-domain

Posted by Oyabi 
Nginx + php-fpm and multi-domain
May 06, 2014 12:56PM
I have 3 domain name, 1 server and 1 IPv4 and 1ipv6. I’ve set a record to my ipv4 (I doesn’t use IPv6 right now). My 3 sites use Wordpress. I have configured Nginx, and php-fpm for a domain.

/etc/nginx/conf.d/php5-fpm :

upstream php5-fpm-sock {
server unix:/var/run/php5-fpm.sock; }

/etc/nginx/sites-available/domain.com.conf :

server {
listen 80;
server_name domain.com;

root /var/www/domain.com;
index index.php index.html;

#charset koi8-r;
access_log /var/log/nginx/domain.com.access.log;
error_log /var/log/nginx/domain.com.error.log;

#include global/common.conf;
#include global/wordpress.conf;

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

location ~ \.php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass php5-fpm-sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}

/etc/nginx/sites-available/totaly-different-domain.com.conf :

server {
listen 80;
server_name totaly-different-domain.com;

root /var/www/totaly-different-domain.com;
index index.php index.html;

#charset koi8-r;
access_log /var/log/nginx/totaly-different-domain.com.access.log;
error_log /var/log/nginx/totaly-different-domain.com.error.log;


#include global/common.conf;
#include global/wordpress.conf;

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

location ~ \.php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass php5-fpm-sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}

Problem : domain 1 appears on my navigator when I type domain.com but also when I type totaly-different-domain.com.

domain.com -> show domain.com
totaly-different-domain.com -> show domain.com

PS : I know I can optimize that but I want to understand why I have got this problem before.

Of course I have restart Nginx and php-fpm.
I use nginx 1.6.0 and PHP 5.4.4-14+deb7u9 (fpm-fcgi) (built: Apr 18 2014 14:36:29) on debian 7 wheezy.
Maybe I must change a parameter in php-fpm, but I don't know what.
Re: Nginx + php-fpm and multi-domain
May 06, 2014 04:25PM
Ok I have find solution.
You must replace :
server_name totaly-different-domain.com;
by
server_name totaly-different-domain.com www.totaly-different-domain.com;

Same thing for domain.com.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 254
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