【问题标题】:Cannot connect to apache server from local machine无法从本地计算机连接到 apache 服务器
【发布时间】:2015-11-29 18:05:25
【问题描述】:

我已经在 Linux 服务器 CentOS 6.4 上安装了 apache 和 php。我遵循了这些步骤

yum install -y httpd
/sbin/service httpd restart
yum install -y php php-mysql
yum install -y mod_ssl openssl
/sbin/service httpd restart
service iptables stop

我将 /etc/httpd/conf/httpd.conf 中的 ServerName 更改为

#ServerName www.example.com:80

ServerName 172.32.35.14 (ip address of the server)
/sbin/service httpd restart

我有一个带有以下代码的 php 示例:

<?php
phpinfo();
?>

但是当我尝试从本地计算机访问页面http://172.32.35.14/info.php 时,它显示“加载页面有问题”。然而,当我从 172.32.35.15 连接到页面时,我得到了正确的响应

我的 ISP 不阻止 http 请求。 172.* 网络是一个 VPN。我连接到 VPN,能够 ping 机器,使用 putty 与机器建立 ssh 连接。但是当我无法从本地机器访问 php 页面时。

我错过了什么?请指教

netstat -tulpn 输出为:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1235/rpcbind
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      4406/sshd
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      4198/cupsd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      4636/master
tcp        0      0 0.0.0.0:52330               0.0.0.0:*                   LISTEN      1253/rpc.statd
tcp        0      0 :::111                      :::*                        LISTEN      1235/rpcbind
tcp        0      0 :::80                       :::*                        LISTEN      30170/httpd
tcp        0      0 :::22                       :::*                        LISTEN      4406/sshd
tcp        0      0 ::1:631                     :::*                        LISTEN      4198/cupsd
tcp        0      0 ::1:25                      :::*                        LISTEN      4636/master
tcp        0      0 :::443                      :::*                        LISTEN      30170/httpd
tcp        0      0 :::46690                    :::*                        LISTEN      1253/rpc.statd
udp        0      0 0.0.0.0:1005                0.0.0.0:*                               1253/rpc.statd
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               1235/rpcbind
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               4198/cupsd
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               1129/dhclient
udp        0      0 0.0.0.0:986                 0.0.0.0:*                               1235/rpcbind
udp        0      0 0.0.0.0:39783               0.0.0.0:*                               1253/rpc.statd
udp        0      0 :::111                      :::*                                    1235/rpcbind
udp        0      0 :::38152                    :::*                                    1253/rpc.statd
udp        0      0 :::986                      :::*                                    1235/rpcbind

iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

【问题讨论】:

  • 172.32.35.15 是在同一个子网还是和服务器连接到同一个交换机?尝试更改 httpd 的端口?
  • 和172.32.35.14在同一个子网
  • 尝试使用nmap检查是否可以连接到服务器的80端口。
  • 我的本地机器是windows :(我需要visual c++ env来安装nmap,很遗憾我不能

标签: php linux apache centos


【解决方案1】:

请确认你的服务器(172.32.35.14)你安装了php和mysql对吗?

你的本地机器ip是多少?

请在本地机器上运行 tracert 和 nslookup 命令:

tracert 172.32.35.14

nslookup 172.32.35.14

并查看丢包的位置。

【讨论】:

  • 这里是输出:C:\Windows\System32&gt;tracert 172.32.35.14 Tracing route to bp-lamp325-my-apachephp-mp6gbdribkaj [172.32.35.14] over a maximum of 30 hops: 1 395 ms 382 ms 435 ms 10.200.200.200 2 317 ms 383 ms 452 ms 172.23.1.1 3 544 ms 406 ms 324 ms bp-lamp325-my-apachephp-mp6gbdribkaj [172.32.35.14] Trace complete. C:\Windows\System32&gt;nslookup 172.32.35.14 Server: c4p-dns-vip1.in.ibm.com Address: 9.0.146.50 *** c4p-dns-vip1.in.ibm.com can't find 172.32.35.14: Non-existent domain
  • 一切似乎都很好。你能检查你的httpd.conf &lt;Directory "/var/www/html"&gt; Options Indexes SymLinksIfOwnerMatch AllowOverride None Order allow,deny Allow from all &lt;/Directory&gt; 它应该有Allow from all
  • 这是我的 httpd.conf 文件中的值&lt;Directory "/var/www/html"&gt; Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all &lt;/Directory&gt;
  • 我改成Options Indexes SymLinksIfOwnerMatch 重启httpd服务试过了还是无效
  • 请从您的服务器 (172.32.35.14) 运行 curl -I http://172.32.35.14/info.php curl -I http://localhost/info.php 并检查两个输出 200 Found
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-14
  • 1970-01-01
  • 2015-12-25
  • 1970-01-01
  • 2019-09-21
  • 1970-01-01
相关资源
最近更新 更多