【发布时间】:2017-11-02 19:05:39
【问题描述】:
基本上,我需要在一个主机和一个注册域名上逻辑分离 2 个站点。 首先,我使用 CNAME 记录设置了一个子域。然后我为域和子域创建了2个文件(没有语法错误,更改后nginx重新启动):
子域.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;}}
域.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 应该用几个实例吗?
【问题讨论】: