基本上我需要在逻辑上将一个主机和一个域名注册的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吗?