V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
freejishu
V2EX  ›  PHP

Unable to find the socket transport "http"/"https"

  •  
  •   freejishu · 2016-06-06 13:15:34 +08:00 · 2320 次点击
    这是一个创建于 2873 天前的主题,其中的信息可能已经有所发展或是发生改变。

    今天给 dz 修锅,结果发现 UCenter 通讯不正常。我做了如下测试:

    1 、按照网上的初级教程重置通讯 KEY 等,无效。

    2 、修改后台 ip+VPS hosts 都指向 127.0.0.1 (但是事实证明就是 127.0.0.1 )

    3 、把网站的 80 口打开,因为以前都是 https 强制( 301 在前端 CDN 上)

    4 、试着查查看是不是环境(fsockopen)问题,然后:

    <?php
    
    $fp = fsockopen("http://xxxxxxxx",
     80, $errno, $errstr, 30);   
    if (!$fp) {   
    echo "$errstr ($errno)<br />\n";   
    } else {   
    $out = "GET / HTTP/1.1\r\n";   
    $out .= "Host: xxxxxxxxx\r\n";   
    $out .= "Connection: Close\r\n\r\n";   
     
    fwrite($fp, $out);   
    while (!feof($fp)) {   
    echo fgets($fp, 128);   
    }   
    fclose($fp);   
    }  ;
    
    ?>
    

    (allow_url_fopen:On) 结果 PHP 给我返回了这么一句: Unable to find the socket transport "http" - did you forget to enable it when you configured PHP? (42852192)。更换成 https 后引号内又变成了 https 。 麻麻,为何别人家的机器不这样 QAQ

    搜索了半天,发现出现这个问题的大多是 windows , linux 很少见,因而没有找到合适的解决方案(那些提问者也都不了了之)。

    机器内的 curl 正常,不论有没有 s ,也就意味着 openssl 应该没啥问题。——求助广大 V 友们,问题到底出现在哪里?如果需要重新编译 php ,又需要加上哪个参数?(原来是 lnmp 包)

    附: lnmp 编译参数:

    './configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir=/usr/local/freetype' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-opcache' '--enable-intl' '--with-xsl'
    

    附 2 :因为是 DZ ,所以不太可能一个一个改成 curl 。

    oott123
        1
    oott123  
       2016-06-06 13:24:44 +08:00
    fsockopen 是个 socket 连接函数,接收的第一个参数是 hostname ,本来就不能 open http:// 啥的吧……
    你把 http:// 去掉看看……
    freejishu
        2
    freejishu  
    OP
       2016-06-06 15:05:48 +08:00
    @oott123 =。=去掉之后是 400BadRequest (但是我没设置任何验证)

    凭着第六感重新编译了 PHP (原来参数),UC 通讯正常了。。

    本题结贴。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3730 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 04:16 · PVG 12:16 · LAX 21:16 · JFK 00:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.