【问题标题】:Serving domain and sub-domain with Nginx and php-fpm使用 Nginx 和 php-fpm 服务域和子域
【发布时间】: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 应该用几个实例吗?

【问题讨论】:

    标签: php nginx dns subdomain


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-01-11
        • 2013-11-10
        • 2016-06-17
        • 2023-01-07
        • 2020-11-28
        • 2013-02-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多