【问题标题】:Issues settings up subdomains w/ nginx使用 nginx 设置子域的问题
【发布时间】:2016-01-17 22:49:01
【问题描述】:

我正在尝试为我的网站为 PhpMyAdmin 设置一个子域,但我在尝试使其正常工作时遇到了问题。当我访问我的网站时,一切都按预期工作,但是当我访问我设置的子域时,它会向我显示常规网站,并且与 PhpMyAdmin 没有任何关系。我一直在尝试几种不同的组合来尝试使其正常工作,但我无法弄清楚。这是我第一次尝试使用 nginx,所以我需要一些帮助。这是我的以下配置文件。

/etc/nginx/nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

/etc/nginx/conf.d/default.conf

server {
    listen       80;
    server_name  www.cozykittygames.com;

    root   /usr/share/nginx/html;
    index  index.php index.html index.htm;

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

server {
    server_name  pma.cozykittgames.com;
    root    /usr/share/phpmyadmin;
}

我已经尝试了我能想到的一切,我的子域被设置为常规域的精确副本,只是 server_name 不同。在这一点上,如果我能让子域指向正确的文件夹,那就太好了。

【问题讨论】:

    标签: nginx subdomain


    【解决方案1】:

    问题是您的服务器名称拼写错误,在“kitty”中遗漏了“y”。应该是:

     server_name  pma.cozykittygames.com;
    

    【讨论】:

    • 我也没有直接发现错字。我的第一个想法是检查 DNS,因为您提供了真实域名。当我在 pma 子域上运行 dig 并注意到它没有解决时,我才注意到错字。
    猜你喜欢
    • 2012-09-19
    • 1970-01-01
    • 2014-12-06
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 2013-01-22
    • 2011-08-21
    • 2013-12-04
    相关资源
    最近更新 更多