2014-11-05 199 views
1

我在我的网络服务器上使用NGINX和MariaDB。网站是通过IP地址访问,但不是域名?

我将操作系统从Debian Squeeze升级到了Debian Wheezy。完成此操作后,我完全删除了Apache服务器和Mysql。然后,我安装了Nginx和MariaDB。

现在,我通过IP地址访问我的网站,但我无法从域名访问它。我试图解决它,但我不能成功。

我的域名:http://tinyurl.com/lg4kjsg

域名IP:37.148.208.85

等/ nginx的/ nginx.conf

user www-data; 
worker_processes 1; 
pid /var/run/nginx.pid; 

events { 
    worker_connections 768; 
} 

http { 
    sendfile on; 
    tcp_nopush on; 
    tcp_nodelay on; 
    keepalive_timeout 65; 
    types_hash_max_size 2048; 
    include /etc/nginx/mime.types; 
    default_type application/octet-stream; 

    access_log /var/log/nginx/access.log; 
    error_log /var/log/nginx/error.log; 

    gzip on; 
    gzip_disable "msie6"; 

    include /etc/nginx/conf.d/*.conf; 
    include /etc/nginx/sites-enabled/*; 
} 

等/ nginx的/网站可用/默认

server { 
    listen 80; ## listen for ipv4; this line is default and implied 
    listen [::]:80 default_server ipv6only=on; ## listen for ipv6 

    root /var/www/virtual; 
    index index.html index.htm index.php; 

    server_name localhost; 

    location/{ 
    try_files $uri $uri/ /index.html; 
} 

location /doc/ { 
    alias /usr/share/doc/; 
    autoindex on; 
    allow 127.0.0.1; 
    allow ::1; 
    deny all; 
} 

location ~ \.php$ { 
    try_files $uri =404; 
    fastcgi_split_path_info ^(.+\.php)(/.+)$; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    include fastcgi_params; 
    } 
} 

等/ nginx的/网站可用/ MYDOMAIN

server { 
    listen 80; 
    server_name www.mydomain.com mydomain.com; 
    access_log /var/www/virtual/mydomain.com/logs/access.log; 
    error_log /var/www/virtual/mydomain.com/logs/error.log; 

location/{ 
    root /var/www/virtual/mydomain.coom/htdocs; 
    index index.php index.html index.htm; 

if (-f $request_filename) { 
    expires 30d; 
    break; 
} 

if (!-e $request_filename) { 
    rewrite ^(.+)$ /index.php?q=$1 last; 
} 

location ~ .php$ { 
    try_files $uri =404; #to prevent zero day exploitsts 
    fastcgi_pass localhost:9000; # port where FastCGI processes were spawned 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME /var/www/virtual/mydomain.com/htdocs/$fastcgi_script_name; 
    fastcgi_param PATH_INFO    $fastcgi_script_name; 
    include /etc/nginx/fastcgi_params; 
    } 

location /phpmyadmin { 
     root /usr/share/; 
     index index.php index.html index.htm; 
     location ~ ^/phpmyadmin/(.+\.php)$ { 
       try_files $uri =404; 
       root /usr/share/; 
       fastcgi_pass 127.0.0.1:9000; 
       fastcgi_index index.php; 
       #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
       fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$fastcgi_script_name; 
       include /etc/nginx/fastcgi_params; 
     } 
       location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { 
       root /usr/share/; 
     } 
    } 

} 
} 

etc/hosts中

127.0.0.1 localhost 
# nginx virtual hosts 
37.148.208.85 www.mydomain.com mydomain.com 

等/ resolv.conf的

search domain.name 
nameserver 89.19.21.250 
nameserver 89.19.21.251 

任何解决方案/建议将不胜感激!谢谢。

回答

1

看起来您的域名ge ***。net尚未在DNS中注册。

[[email protected] ~]# ping gencharitaci.net 
ping: unknown host gencharitaci.net 
[[email protected] ~]# dig gencharitaci.net 

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> gencharitaci.net 
;; global options: +cmd 
;; Got answer: 
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 15999 
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 

;; QUESTION SECTION: 
;gencharitaci.net.    IN  A 

;; Query time: 103 msec 
;; SERVER: 10.0.80.11#53(10.0.80.11) 
;; WHEN: Wed Nov 5 07:21:50 2014 
;; MSG SIZE rcvd: 34 
+0

我该如何解决这个问题? – YoungS 2014-11-05 08:30:33

+0

我得到了这些结果'[root @〜]#ping gencharitaci.net来自www.gencharitaci.net的64字节(37.148.208.85):icmp_req = 76 ttl = 64 time = 0.055 ms'[root @〜]#dig gencharitaci .net v; <<>> DiG 9.8.4-rpz2 + rl005.12-P1 <<>> gencharitaci.net ;;全局选项:+ cmd ;;连接超时;没有服务器无法到达 – YoungS 2014-11-05 08:36:51

+0

谁是你的提供者?请在那里配置您的域名服务器。 如果您的域位于/ etc/hosts或/ etc/sysconfig/network中,那么您的ping可以工作,因此它在本地解析。 – 2014-11-05 08:42:30

1

编辑此文件后,我解决了我的问题;

etc/bind/named.conf.local我在旧备份中找到了这个文件。我已经添加了这些行,并修复了我的问题。

// [gencharitaci.net] entry BEGIN 
zone "gencharitaci.net" { 
    type master; 
    file "/var/cache/bind/gencharitaci.net.db"; 
    allow-transfer { localhost; }; 
    notify yes; 
}; 
// [gencharitaci.net] entry ENDING 

// [gencharitaci.com] entry BEGIN 
zone "gencharitaci.com" { 
    type master; 
    file "/var/cache/bind/gencharitaci.com.db"; 
    allow-transfer { localhost; }; 
    notify yes; 
}; 
// [gencharitaci.com] entry ENDING 

// [gencharitaci.org] entry BEGIN 
zone "gencharitaci.org" { 
    type master; 
    file "/var/cache/bind/gencharitaci.org.db"; 
    allow-transfer { localhost; }; 
    notify yes; 
}; 
// [gencharitaci.org] entry ENDING 

// [admin.0050569fc491.gencharitaci.net] entry BEGIN 
zone "admin.0050569fc491.gencharitaci.net" { 
    type master; 
    file "/var/cache/bind/admin.0050569fc491.gencharitaci.net.db"; 
    allow-transfer { localhost; }; 
    notify yes; 
}; 
// [admin.0050569fc491.gencharitaci.net] entry ENDING