Php套接字,Apache和CentOS 6.3给出了权限被拒绝
发布时间:2020-12-13 22:14:47 所属栏目:PHP教程 来源:网络整理
导读:我想要做的是运行一个简单的 PHP脚本,检查游戏服务器是否在线并从中获取一些信息.我在WAMP服务器的本地机器上运行完全相同的脚本,我只是取消注释php_openssl.dll和php_sockets.dll,并且 – 瞧 – 它按预期工作. 但后来我们的生产环境!我通常和Debian一起工?
我想要做的是运行一个简单的
PHP脚本,检查游戏服务器是否在线并从中获取一些信息.我在WAMP服务器的本地机器上运行完全相同的脚本,我只是取消注释php_openssl.dll和php_sockets.dll,并且 – 瞧 – 它按预期工作.
但后来我们的生产环境!我通常和Debian一起工??作,但是我们的主机决定在我们的专用服务器上安装CentOS,因为NIC在Debian中失败了,而且这只是麻烦了. 我克服了一些问题,并留下了这个问题:如何修复PHP套接字?我读到我需要php-common,所以我安装了这个: # yum install php-common 然后我检查了phpinfo(),我得到了这个 './configure' '--with-openssl' '--enable-sockets' ... 所以如果你问我这个看起来很好,openssl和socket都已安装并且应该正常工作,但事实并非如此.我在Stack Overflow上找到了这个脚本: <?php //just in case if (!extension_loaded('sockets')) { die('The sockets extension is not loaded.'); } echo '<p><strong>Establishing connection...</strong></p>'; $socket = socket_create(AF_INET,SOCK_STREAM,0); if (!socket_connect($socket,"stackoverflow.com",80)) { die('Socket error : '.socket_strerror(socket_last_error())); } echo '<p><strong>Connection successful!</strong></p>'; $request = join("n",array( "GET / HTTP/1.1","Connection: close","Host: stackoverflow.com","User-Agent: Mozilla/5.0 (Windows NT 6.1)","Accept: text/html,*/*;q=0.8","")); socket_write($socket,$request,strlen($request)); $response = socket_read($socket,2048); echo "<p><strong>This is the received data : </strong></p>"; echo '<pre>'.htmlentities($response).'</pre>'; socket_close($socket); 这个输出让我完全惊讶: Establishing connection... Connection successful! This is the received data : HTTP/1.0 408 Request Time-out Cache-Control: no-cache Connection: close Content-Type: text/html <html><body><h1>408 Request Time-out</h1> Your browser didn't send a complete request in time. </body></html> 但是,我的剧本还没有运作? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |