2017-06-01 84 views
0

基本上我需要在逻辑上将一个主机和一个域名注册的2个站点分开。 首先,我使用CNAME记录设置了一个子域。然后,我创建了2个文件的域和子域(没有语法错误,nginx的更改后重新启动):用Nginx和php服务域名和子域名-fpm

subdomain.conf

server { 
listen 80; 
server_name sub.domain.com; 
index index.php index.html; 
root /web/www/sub.domain.com; 
access_log off; 
server_tokens off; 

location ~ \.php$ { 
    try_files $uri =404; 
    fastcgi_pass unix:/webserv/var/php-cgi.sock; 
    fastcgi_index index.php; 
    include /webserv/nginx/conf/fastcgi.conf;}} 

domain.conf

server { 
listen 80; 
server_name domain.com; 
index index.php index.html; 
root /web/www/domain.com; 
access_log off; 
server_tokens off; 

location ~ \.php$ { 
    try_files $uri =404; 
    fastcgi_pass unix:/webserv/var/php-cgi.sock; 
    fastcgi_index index.php; 
    include /webserv/nginx/conf/fastcgi.conf;}} 

但只有其中一个正在工作,而另一个浏览器的请求甚至不会到达nginx,并且最终它表示页面加载时间太长。这样做最简单的方法是什么?应该使用几个nginx实例,php-fpm吗?

回答

1

如果启用seconde文件并且错误的nginx会触发服务器错误,但是您所说的问题来自您的域名,可能是配置错误或尚未传播,那么您的配置看起来很好。

0

已解决,它不工作,因为我在本地机器上使用谷歌公共DNS(谁会想到)