http状态码一览

http状态吗及解释,英文版

1xx

code reason description spec
1xx Informational “indicates an interim response for communicating connection status or request progress prior to completing the requested action and sending a final response.” ~ sure RFC7231#6.2,
RFC2616#10.1
100 Continue “indicates that the initial part of a request has been received and has not yet been rejected by the server.” RFC7231#6.2.1,
RFC2616#10.1.1
101 Switching Protocols “indicates that the server understands and is willing to comply with the client’s request, via the Upgrade header field, for a change in the application protocol being used on this connection.” RFC7231#6.2.2,
RFC2616#10.1.2

2xx

code reason description spec
2xx Successful “indicates that the client’s request was successfully received, understood, and accepted.” ~ cool RFC7231#6.3,
RFC2616#10.2
200 OK “indicates that the request has succeeded.” RFC7231#6.3.1,
RFC2616#10.2.1
201 Created “indicates that the request has been fulfilled and has resulted in one or more new resources being created.” RFC7231#6.3.2,
RFC2616#10.2.2
202 Accepted “indicates that the request has been accepted for processing, but the processing has not been completed.” RFC7231#6.3.3,
RFC2616#10.2.3
203 Non-Authoritative Information “indicates that the request was successful but the enclosed payload has been modified from that of the origin server’s 200 (OK) response by a transforming proxy.” RFC7231#6.3.4,
RFC2616#10.2.4
204 No Content “indicates that the server has successfully fulfilled the request and that there is no additional content to send in the response payload body.” RFC7231#6.3.5,
RFC2616#10.2.5
205 Reset Content “indicates that the server has fulfilled the request and desires that the user agent reset the “document view”, which caused the request to be sent, to its original state as received from the origin server.” RFC7231#6.3.6,
RFC2616#10.2.6
206 Partial Content “indicates that the server is successfully fulfilling a range request for the target resource by transferring one or more parts of the selected representation that correspond to the satisfiable ranges found in the requests’s Range header field.” RFC7233#4.1,
RFC2616#10.2.7

3xx

code reason description spec
3xx Redirection “indicates that further action needs to be taken by the user agent in order to fulfill the request.” ~ ask that dude over there RFC7231#6.4,
RFC2616#10.3
300 Multiple Choices “indicates that the target resource has more than one representation, each with its own more specific identifier, and information about the alternatives is being provided so that the user (or user agent) can select a preferred representation by redirecting its request to one or more of those identifiers.” RFC7231#6.4.1,
RFC2616#10.3.1
301 Moved Permanently “indicates that the target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.” RFC7231#6.4.2,
RFC2616#10.3.2
302 Found “indicates that the target resource resides temporarily under a different URI.” RFC7231#6.4.3,
RFC2616#10.3.3
303 See Other “indicates that the server is redirecting the user agent to a different resource, as indicated by a URI in the Location header field, that is intended to provide an indirect response to the original request.” RFC7231#6.4.4,
RFC2616#10.3.4
304 Not Modified “indicates that a conditional GET request has been received and would have resulted in a 200 (OK) response if it were not for the fact that the condition has evaluated to false.” RFC7232#4.1,
RFC2616#10.3.5
305 Use Proxy deprecated RFC7231#6.4.5,
RFC2616#10.3.6
306 unused RFC7231#6.4.6,
RFC2616#10.3.7
307 Temporary Redirect “indicates that the target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI.” RFC7231#6.4.7,
RFC2616#10.3.8

4xx

code reason description spec
4xx Client Error “indicates that the client seems to have erred.” ~ you fucked up RFC7231#6.5,
RFC2616#10.4
400 Bad Request “indicates that the server cannot or will not process the request because the received syntax is invalid, nonsensical, or exceeds some limitation on what the server is willing to process.” RFC7231#6.5.1,
RFC2616#10.4.1
401 Unauthorized “indicates that the request has not been applied because it lacks valid authentication credentials for the target resource.” RFC7235#6.3.1,
RFC2616#10.4.2
402 Payment Required reserved RFC7231#6.5.2,
RFC2616#10.4.3
403 Forbidden “indicates that the server understood the request but refuses to authorize it.” RFC7231#6.5.3,
RFC2616#10.4.4
404 Not Found “indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists.” RFC7231#6.5.4,
RFC2616#10.4.5
405 Method Not Allowed “indicates that the method specified in the request-line is known by the origin server but not supported by the target resource.” RFC7231#6.5.5,
RFC2616#10.4.6
406 Not Acceptable “indicates that the target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation.” RFC7231#6.5.6,
RFC2616#10.4.7
407 Proxy Authentication Required “is similar to 401 (Unauthorized), but indicates that the client needs to authenticate itself in order to use a proxy.” RFC7235#3.2,
RFC2616#10.4.8
408 Request Timeout “indicates that the server did not receive a complete request message within the time that it was prepared to wait.” RFC7231#6.5.7,
RFC2616#10.4.9
409 Conflict “indicates that the request could not be completed due to a conflict with the current state of the resource.” RFC7231#6.5.8,
RFC2616#10.4.10
410 Gone “indicates that access to the target resource is no longer available at the origin server and that this condition is likely to be permanent.” RFC7231#6.5.9,
RFC2616#10.4.11
411 Length Required “indicates that the server refuses to accept the request without a defined Content-Length.” RFC7231#6.5.10,
RFC2616#10.4.12
412 Precondition Failed “indicates that one or more preconditions given in the request header fields evaluated to false when tested on the server.” RFC7232#4.2,
RFC2616#10.4.13
413 Payload Too Large “indicates that the server is refusing to process a request because the request payload is larger than the server is willing or able to process.” RFC7231#6.5.11,
RFC2616#10.4.14
414 URI Too Long “indicates that the server is refusing to service the request because the request-target is longer than the server is willing to interpret.” RFC7231#6.5.12,
RFC2616#10.4.15
415 Unsupported Media Type “indicates that the origin server is refusing to service the request because the payload is in a format not supported by the target resource for this method.” RFC7231#6.5.13,
RFC2616#10.4.16
416 Range Not Satisfiable “indicates that none of the ranges in the request’s Range header field overlap the current extent of the selected resource or that the set of ranges requested has been rejected due to invalid ranges or an excessive request of small or overlapping ranges.” RFC7233#4.4,
RFC2616#10.4.17
417 Expectation Failed “indicates that the expectation given in the request’s Expect header field could not be met by at least one of the inbound servers.” RFC7231#6.5.14,
RFC2616#10.4.18
418 I’m a teapot “Any attempt to brew coffee with a teapot should result in the error code 418 I’m a teapot.” RFC2324#2.3.2
426 Upgrade Required “indicates that the server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.” RFC7231#6.5.15

5xx

code reason description spec
5xx Server Error “indicates that the server is aware that it has erred or is incapable of performing the requested method.” ~ we fucked up RFC7231#6.6,
RFC2616#10.5
500 Internal Server Error “indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.” RFC7231#6.6.1,
RFC2616#10.5.2
501 Not Implemented “indicates that the server does not support the functionality required to fulfill the request.” RFC7231#6.6.2,
RFC2616#10.5.3
502 Bad Gateway “indicates that the server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.” RFC7231#6.6.3,
RFC2616#10.5.4
503 Service Unavailable “indicates that the server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay.” RFC7231#6.6.4,
RFC2616#10.5.5
504 Gateway Time-out “indicates that the server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request.” RFC7231#6.6.5,
RFC2616#10.5.6
505 HTTP Version Not Supported “indicates that the server does not support, or refuses to support, the protocol version that was used in the request message.” RFC7231#6.6.6,
RFC2616#10.5.6

Extensions

code reason description spec
102 Processing “is an interim response used to inform the client that the server has accepted the complete request, but has not yet completed it.” RFC5218#10.1
207 Multi-Status “provides status for multiple independent operations.” RFC5218#10.2
226 IM Used “The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.” RFC3229#10.4.1
308 Permanent Redirect “The target resource has been assigned a new permanent URI and any future references to this resource outght to use one of the enclosed URIs. […] This status code is similar to 301 Moved Permanently (Section 7.3.2 of rfc7231), except that it does not allow rewriting the request method from POST to GET.” RFC7538
422 Unprocessable Entity “means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions.” RFC5218#10.3
423 Locked “means the source or destination resource of a method is locked.” RFC5218#10.4
424 Failed Dependency “means that the method could not be performed on the resource because the requested action depended on another action and that action failed.” RFC5218#10.5
428 Precondition Required “indicates that the origin server requires the request to be conditional.” RFC6585#3
429 Too Many Requests “indicates that the user has sent too many requests in a given amount of time (“rate limiting”).” RFC6585#4
431 Request Header Fields Too Large “indicates that the server is unwilling to process the request because its header fields are too large.” RFC6585#5
451 Unavailable For Legal Reasons “This status code indicates that the server is denying access to the resource in response to a legal demand.” draft-ietf-httpbis-legally-restricted-status
506 Variant Also Negotiates “indicates that the server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.” RFC2295#8.1
507 Insufficient Storage “means the method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.” RFC5218#10.6
511 Network Authentication Required “indicates that the client needs to authenticate to gain network access.” RFC6585#6
7xx Developer Error err 7xx-rfc

php使用curl时报错解决方法

问题总结

问:file_get_contents 开启https支持

答:配置php.ini 开启php_openssl.dll 扩展,开启allow_url_fopen=On
代码部分:

1
2
3
4
5
$w = stream_get_wrappers();
echo 'openssl: ', extension_loaded ('openssl') ? 'yes':'no', "\n";
echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n";
echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n";
echo 'wrappers: ', var_export($w);

作用:用于检测配置项是否存在https;

问:curl 抓取网站信息时,出现此错误:This site requires JavaScript and Cookies to be enabled.

答:修改curl 参数CURLOPT_USERAGENT为Google Bot,伪装成google bot去抓取
代码部分:

1
curl_setopt($ch, CURLOPT_USERAGENT, "Google Bot");

作用:伪装成谷歌机器去抓取页面信息

hexo deploy failed

question


INFO Deploying: git

INFO Clearing .deploy folder…

FATAL Something’s wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html

FATAL EACCES: permission denied, open ‘/home/yang/hexo/db.json’

Error: EACCES: permission denied, open ‘/home/yang/hexo/db.json’

* answer:

1. sudo ssh-keygen -t rsa -b 4096 -C “xxx@xxx.com

2. copy /var/root/.ssh/id_rsa/id_rsa_pub -> github/settings/SSH and GPG keys/new ssh key

3. hexo deploy

* answer2:

1. su root

3. hexo deploy

debian 9.4(stretch) install

debian 9 install questions

Distributor ID Desc Third Realease
Debian CDebian GNU/Linux 9.4 (stretch) 9.4
Command showinfo other
uname -r 4.9.0-6-amd64 none
cat /proc/version Linux version 4.9.0-6-amd64 (gcc 6.3.0 20170516(Debian 6.3.0-18+deb9u1)

question

/sys/kernel/debug/vgaswitcheroo/switch: No such file or directory

answer

1. cat /sys/kernel/debug/vgaswitcheroo/switch address:https://bbs.archlinuxcn.org/viewtopic.php?id=2993,

2. https://help.ubuntu.com/community/HybridGraphics,

3. https://askubuntu.comquestions/648426/discrete-graphics-always-dynoff

question

ERROR radeon kernel modesetting for R600 or later requires firmware-amd-graphics.

answer

1. add /etc/apt/sources.list deb http://ftp.us.debian.org/debian/ testing main non-free contrib

2. deb-src http://ftp.us.debian.org/debian/ testing main non-free contrib

3. sudo apt-get update

4. sudo apt-get install firmware-amd-graphics

question

grub rescue

answer

1. ls

2. ls (hd0,x)/boot/grub or (hd1,x)/boot/grub

3. set root=(hd0,5)

4. set prefix=(hd0,5)/boot/grub

5. set insmod /boot/grub

6. set insmod /boot/grub

7. sudo update-grub

8. sudo grub-install /dev/sda

什么是CGI、FastCGI、PHP-CGI、PHP-FPM、Spawn-FCGI?

名词解释

CGI

CGI全称是“公共网关接口”(Common Gateway Interface),HTTP服务器与你的或其它机器上的程序进行“交谈”的一种工具,
其程序须运行在网络服务器上。CGI可以用任何一种语言编写,只要这种语言具有标准输入、输出和环境变量。如php,
perl,tcl等
PS:是一种协议

FastCGI

FastCGI像是一个常驻(long-live)型的CGI,它可以一直执行着,只要激活后,不会每次都要花费时间去fork一次(这是CGI
最为人诟病的fork-and-execute 模式)。它还支持分布式的运算, 即 FastCGI 程序可以在网站服务器以外的主机上执行并
且接受来自其它网站服务器来的请求。FastCGI是语言无关的、可伸缩架构的CGI开放扩展,其主要行为是将CGI解释器进程
保持在内存中并因此获得较高的性能。众所周知,CGI解释器的反复加载是CGI性能低下的主要原因,如果CGI解释器保持在
内存中并接受FastCGI进程管理器调度,则可以提供良好的性能、伸缩性、Fail- Over特性等等。
PS:同样是一种协议

PHP-CGi

PHP-CGI是PHP自带的FastCGI管理器。
PS:PHP解释器

PHP-FPM

PHP-FPM是一个PHP FastCGI管理器,是一个补丁,用于将fastCGI整合进php包中,php5.3.3后已经集成到php中,之前的版
本属于第三方包
PS:php-fpm是fastcgi进程的管理器,用来管理fastcgi进程的,它实现了Fastcgi的程序,被PHP官方收了

Spawn-FCGI

Spawn-FCGI是一个通用的FastCGI管理服务器,它是lighttpd中的一部份,很多人都用Lighttpd的Spawn-FCGI进行FastCGI模
式下的管理工作
PS:一个通用的FastCGI管理服务器

工作原理及联系

CGI:每当客户请求CGI的时候,WEB服务器就请求操作系统生成一个新的CGI解释器进程(如php-cgi.exe,CGI的一个进程则处
理完一个请求后退出,下一个请求来时再创建新进程。当然,这样在访问量很少没有并发的情况也行。可是当访问量增大并
发存在,这种方式就不 适合了。于是就有了fastcgi。
fastCGI:FastCGI像是一个常驻(long-live)型的CGI,它可以一直执行着,只要激活后,不会每次都要花费时间去fork一次
(这是CGI最为人诟病的fork-and-execute 模式)。

FastCGI的工作原理

1、Web Server启动时载入FastCGI进程管理器(IIS ISAPI或Apache Module)
2、FastCGI进程管理器自身初始化,启动多个CGI解释器进程(可见多个php-cgi)并等待来自Web Server的连接。
3、当客户端请求到达Web Server时,FastCGI进程管理器选择并连接到一个CGI解释器。Web server将CGI环境变量和标
准输入发送到FastCGI子进程php-cgi。
4、FastCGI子进程完成处理后将标准输出和错误信息从同一连接返回WebServer。当FastCGI子进程关闭连接时,请求便
告处理完成。FastCGI子进程接着等待并处理来自FastCGI进程管理器(运行在Web Server中)的下一个连接。 在CGI模式中,
php-cgi在此便退出了。
在上述情况中,你可以想象CGI通常有多慢。每一个Web请求PHP都必须重新解析php.ini、重新载入全部扩展并重初始化
全部数据结构。使用FastCGI,所有这些都只在进程启动时发生一次。一个额外的好处是,持续数据库连接可以工作。

FastCGI的不足

因为是多进程,所以比CGI多线程消耗更多的服务器内存,PHP-CGI解释器每进程消耗7至25兆内存,将这个数字乘以50或
100就是很大的内存数。Nginx 0.8.46+PHP 5.2.14(FastCGI)服务器在3万并发连接下,开启的10个Nginx进程消耗150M内存
(15M10=150M),开启的64个php-cgi进程消耗1280M内存(20M64=1280M),加上系统自身消耗的内存,总共消耗不到2GB
内存。如果服务器内存较小,完全可以只开启25个php-cgi进程,这样php-cgi消耗的总内存数才500M。

PHP-CGI的不足

1、php-cgi变更php.ini配置后需重启php-cgi才能让新的php-ini生效,不可以平滑重启
2、直接杀死php-cgi进程,php就不能运行了。(PHP-FPM和Spawn-FCGI就没有这个问题,守护进程会平滑从新生成新的子进程。)

总结

首先,CGI是干嘛的?CGI是为了保证web server传递过来的数据是标准格式的,方便CGI程序的编写者。
web server(比如说nginx)只是内容的分发者。比如,如果请求index.html,那么webserver会去文件系统中找到这个文件
,发送给浏览器,这里分发的是静态数据。好了,如果现在请求的是/index.php,根据配置文件,nginx知道这个不是静态
文件,需要去找PHP解析器来处理,那么他会把这个请求简单处理后交给PHP解析器。Nginx会传哪些数据给PHP解析器呢?
url要有吧,查询字符串也得有吧,POST数据也要有,HTTP header不能少吧,好的,CGI就是规定要传哪些数据、以什么
样的格式传递给后方处理这个请求的协议。仔细想想,你在PHP代码中使用的用户从哪里来的。
  当web server收到/index.php这个请求后,会启动对应的CGI程序,这里就是PHP的解析器。接下来PHP解析器会解
析php.ini文件,初始化执行环境,然后处理请求,再以规定CGI规定的格式返回处理后的结果,退出进程。web server
再把结果返回给浏览器。好了,CGI是个协议,跟进程什么的没关系。那fastcgi又是什么呢?Fastcgi是用来提高CGI程序
性能的。提高性能,那么CGI程序的性能问题在哪呢?”PHP解析器会解析php.ini文件,初始化执行环境”,就是这里了。
标准的CGI对每个请求都会执行这些步骤(不闲累啊!启动进程很累的说!),所以处理每个时间的时间会比较长。这明
显不合理嘛!那么Fastcgi是怎么做的呢?首先,Fastcgi会先启一个master,解析配置文件,初始化执行环境,然后再启
动多个worker。当请求过来时,master会传递给一个worker,然后立即可以接受下一个请求。这样就避免了重复的劳动,
效率自然是高。而且当worker不够用时,master可以根据配置预先启动几个worker等着;当然空闲worker太多时,也会
停掉一些,这样就提高了性能,也节约了资源。这就是fastcgi的对进程的管理。
那PHP-FPM又是什么呢?是一个实现了Fastcgi的程序,被PHP官方收了。
大家都知道,PHP的解释器是php-cgi。php-cgi只是个CGI程序,他自己本身只能解析请求,返回结果,不会进程管理
所以就出现了一些能够调度php-cgi进程的程序,比如说由lighthttpd分离出来的spawn-fcgi。好了PHP-FPM也是这么
个东东,在长时间的发展后,逐渐得到了大家的认可(要知道,前几年大家可是抱怨PHP-FPM稳定性太差的),也越来越流行。
参考地址:
https://www.cnblogs.com/wanghetao/p/3934350.html
https://www.lvtao.net/tool/885.html

你是本站第位访客 本站访客数人次
Fork me on GitHub