我在我的网络服务器上使用 NGINX 和 MariaDB。
我将操作系统从 Debian Squeeze 升级到 Debian Wheezy。在这个操作之后,我已经完全删除了 Apache 服务器和 Mysql。然后,我安装了 Nginx 和 MariaDB。
现在,我通过IP地址访问我的网站,但是我无法通过域名访问它。我尝试修复它,但未能成功。
我的域名:http://tinyurl.com/lg4kjsg
域名IP:37.148.208.85
etc/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/*;
}
etc/nginx/sites-available/default
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;
}
}
etc/nginx/sites-available/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/;
}
}
}
}
等/主机
127.0.0.1 localhost
# nginx virtual hosts
37.148.208.85 www.mydomain.com mydomain.com
etc/resolv.conf
search domain.name
nameserver 89.19.21.250
nameserver 89.19.21.251
任何解决方案/建议将不胜感激!谢谢。
最佳答案
您的域名 ge***.net 似乎尚未在 DNS 中注册。
[root@ ~]# ping gencharitaci.net
ping: unknown host gencharitaci.net
[root@ ~]# 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
关于php - 网站是通过IP地址而不是域名访问的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26752465/