在新安装时 helloworld.php 的 curl 和 wget return 错误 500 但浏览器没问题
Curl and wget return error 500 for helloworld.php on new install but browser is fine
我没有 .htaccess 文件。我有 index.php,它具有以下内容,并且在 Chrome 或 Safari 等浏览器中运行良好:
<?php print "hello world"; ?>
当我在浏览器中加载它时,我得到:hello world。
当我尝试以下任一操作时,我收到错误 500:内部服务器错误。
- /usr/bin/wget http://example.com/index.php
- /usr/bin/wget -nv -t 5 --connect-timeout=4 -w 4 --connect-timeout=20 -nd --no-cache --no-cookies http://example.com/index.pp
- /usr/bin/wget --content-on-error http://example.com/index.php
- /usr/bin/wget --header="Accept: text/html" --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0"
- 卷曲http://example.com/index.php
我检查了所有的 apache 日志文件,除了在网络浏览器中加载它时什么也看不到。
这是 Ubuntu 16.04 php7.0 Apache2。所有全新安装和更新以及截至 2016 年 11 月 3 日的最新版本
我尝试重新安装 wget。我从其他机器和本地机器上尝试了 wget。
我试过将 varnish 放在端口 80 上,将 apache 放在端口 8080 上,但没有任何改变。
Wget 通过调试输出以下内容:
root@one:~# wget --debug http://example.com/index.php
DEBUG output created by Wget 1.17.1 on linux-gnu.
Reading HSTS entries from /root/.wget-hsts
URI encoding = ‘UTF-8’
--2016-11-03 07:51:27-- http://example.com/index.php
Resolving example.com (example.com)... 207.158.37.70
Caching example.com =207.158.37.70
Connecting to example.com (example.com)|207.158.37.70|:80... connected.
Created socket 3.
Releasing 0x0000561eeda0d190 (new refcount 1).
---request begin---
GET /index.php HTTP/1.1
User-Agent: Wget/1.17.1 (linux-gnu)
Accept: */*
Accept-Encoding: identity
Host: example.com
Connection: Keep-Alive
---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 500 Internal Server Error
Server: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.20 OpenSSL/1.0.1f mod_perl/2.0.8 Perl/v5.18.2
Content-Type: text/html; charset=iso-8859-1
Content-Length: 538
Accept-Ranges: bytes
Date: Thu, 03 Nov 2016 14:49:42 GMT
X-Varnish: 2177415129
Age: 0
Via: 1.1 varnish
Connection: keep-alive
---response end---
500 Internal Server Error
Registered socket 3 for persistent reuse.
URI content encoding = ‘iso-8859-1’
Skipping 538 bytes of body: [<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
voztechnologies@gmail.com to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server erroSkipping 26 bytes of body: [r log.</p>
</body></html>
] done.
2016-11-03 07:51:27 ERROR 500: Internal Server Error.
Saving HSTS entries to /root/.wget-hsts
root@one:~#
您的 apache 可能不接受来自 curl 或 wget 的任何用户代理。这可以从 httpd.conf
文件配置(或者可能是其他地方,对此经验不多)。
如果您将浏览器的用户代理与 wget 或 curl 一起使用,它应该适用于您。例如:
wget -U "Opera 11.0" http://www.test.com/
curl -A "Opera 11.0" http://www.test.com/
我注意到服务器上的另一个域名有效。所以,我复制了虚拟主机,重新加载了 apache,但它仍然无法正常工作。我把一切都做得很准确。最后我看到 DNS 指向我的开发服务器,它没有监听我的域名并返回错误 500。
已更新 DNS,节目已恢复。感谢您帮助我解决问题![=10=]
我没有 .htaccess 文件。我有 index.php,它具有以下内容,并且在 Chrome 或 Safari 等浏览器中运行良好:
<?php print "hello world"; ?>
当我在浏览器中加载它时,我得到:hello world。 当我尝试以下任一操作时,我收到错误 500:内部服务器错误。
- /usr/bin/wget http://example.com/index.php
- /usr/bin/wget -nv -t 5 --connect-timeout=4 -w 4 --connect-timeout=20 -nd --no-cache --no-cookies http://example.com/index.pp
- /usr/bin/wget --content-on-error http://example.com/index.php
- /usr/bin/wget --header="Accept: text/html" --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0"
- 卷曲http://example.com/index.php
我检查了所有的 apache 日志文件,除了在网络浏览器中加载它时什么也看不到。
这是 Ubuntu 16.04 php7.0 Apache2。所有全新安装和更新以及截至 2016 年 11 月 3 日的最新版本
我尝试重新安装 wget。我从其他机器和本地机器上尝试了 wget。
我试过将 varnish 放在端口 80 上,将 apache 放在端口 8080 上,但没有任何改变。
Wget 通过调试输出以下内容:
root@one:~# wget --debug http://example.com/index.php
DEBUG output created by Wget 1.17.1 on linux-gnu.
Reading HSTS entries from /root/.wget-hsts
URI encoding = ‘UTF-8’
--2016-11-03 07:51:27-- http://example.com/index.php
Resolving example.com (example.com)... 207.158.37.70
Caching example.com =207.158.37.70
Connecting to example.com (example.com)|207.158.37.70|:80... connected.
Created socket 3.
Releasing 0x0000561eeda0d190 (new refcount 1).
---request begin---
GET /index.php HTTP/1.1
User-Agent: Wget/1.17.1 (linux-gnu)
Accept: */*
Accept-Encoding: identity
Host: example.com
Connection: Keep-Alive
---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 500 Internal Server Error
Server: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.20 OpenSSL/1.0.1f mod_perl/2.0.8 Perl/v5.18.2
Content-Type: text/html; charset=iso-8859-1
Content-Length: 538
Accept-Ranges: bytes
Date: Thu, 03 Nov 2016 14:49:42 GMT
X-Varnish: 2177415129
Age: 0
Via: 1.1 varnish
Connection: keep-alive
---response end---
500 Internal Server Error
Registered socket 3 for persistent reuse.
URI content encoding = ‘iso-8859-1’
Skipping 538 bytes of body: [<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
voztechnologies@gmail.com to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server erroSkipping 26 bytes of body: [r log.</p>
</body></html>
] done.
2016-11-03 07:51:27 ERROR 500: Internal Server Error.
Saving HSTS entries to /root/.wget-hsts
root@one:~#
您的 apache 可能不接受来自 curl 或 wget 的任何用户代理。这可以从 httpd.conf
文件配置(或者可能是其他地方,对此经验不多)。
如果您将浏览器的用户代理与 wget 或 curl 一起使用,它应该适用于您。例如:
wget -U "Opera 11.0" http://www.test.com/
curl -A "Opera 11.0" http://www.test.com/
我注意到服务器上的另一个域名有效。所以,我复制了虚拟主机,重新加载了 apache,但它仍然无法正常工作。我把一切都做得很准确。最后我看到 DNS 指向我的开发服务器,它没有监听我的域名并返回错误 500。
已更新 DNS,节目已恢复。感谢您帮助我解决问题![=10=]