cURL + Laravel Valet + dnsmasq not working

前端 未结 5 1129
南笙
南笙 2020-12-15 08:11

when I execute a PHP script which runs a cURL request to a .test domain that is setup on my Mac with Laravel Valet/dnsmasq, I get this error printed :

相关标签:
5条回答
  • 2020-12-15 08:51

    This problem is caused by curl versions, can you check your curl versions from terminal by

    curl --version and php --ri curl

    When you run php --ri curl you will see cURL Information => 7.63.0 this line.

    Then you can compare your versions and you see which curl version is not working with dnsmasq.

    I encountered this problem and my curl version was 7.64.0 in php.


    For solve that issue:

    You can uninstall curl-openssl, this command will remove last version of curl-openssl:

    brew uninstall curl-openssl --ignore-dependencies
    

    Then restart php:

    brew services restart php
    

    After restarting, php will see curl which is /usr/bin/curl and this version can access local domain.

    0 讨论(0)
  • 2020-12-15 09:00

    Adding 127.0.0.1 to my DNS settings fixed this issue for me. i.e. System Preferences -> Network -> Advance -> DNS

    And Run valet restart afterwards

    0 讨论(0)
  • 2020-12-15 09:01

    I solved this by adding domain.test to /etc/hosts

    i.e., in the hosts file add: 127.0.0.1 domain.test

    0 讨论(0)
  • 2020-12-15 09:08

    ....After restarting, php will see curl which is /usr/bin/curl and this version can access local domain.

    After restarting too the valet: valet restart

    0 讨论(0)
  • 2020-12-15 09:15

    Just spent the last hour on this. I had a similar problem with curl through PHP not resolving with Valet specially for SSL. I tried changing curl-openssl versions and also setting my domain in the host file etc. Nothing worked apart from the following:

        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    

    This is due to the valet SSL not being verified by Curl. Once I added this option to my curl request I was able to fetch data from my local valet url.

    0 讨论(0)
提交回复
热议问题