我知道這可能看起來與已經存在的許多問題相似,但我已經閱讀了幾十篇,但我仍然遇到同樣的問題。我的代碼在我的本地機器上運行良好,我的 Raspberry Pi 是由完全相同的設定腳本配置的,但它在 Pi 上不起作用。
我的作業系統是帶有內核版本的 Raspbian 10 (Buster) 5.10.103-v7l 。我正在運行 PHP 8.1,以及以下命令中的其他包:sudo apt install -y php8.1-common php8.1-cli php8.1-fpm php8.1-xml php8.1-curl
php -m列出 curl 并php -i顯示phpinfo()cURL 已安裝并啟用:
cURL support => enabled
cURL Information => 7.64.0
我知道 cURL 已安裝并啟用,那么如何讓我的 PHP 識別和使用該包?它在我的本地 Linux 機器上完美運行,但在 Pi 上卻不行。我已經重新啟動了我的服務器和我的整個機器,但都沒有改變。我跑了sudo apt update && sudo apt upgrade,一切都是最新的版本。
我的服務器上的“有問題”的代碼片段如下:
require "vendor/autoload.php";
use Symfony\Component\Panther\Client;
$options = [
"--headless",
"--window-size=1200,1100",
"--no-sandbox",
"--disable-gpu",
"--disable-dev-shm-usage",
];
$query = urlencode($_GET["q"]);
$url ="/search?hl=en&tbo=d&site=&source=hp&q=".$query;
$client = Client::createChromeClient("/usr/lib/chromium-browser/chromedriver", $options, [], "http://www.google.com");
$client->request("GET", $url);
我的完整錯誤日志是:
*168 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function Facebook\WebDriver\Remote\curl_init() in /var/lib/jenkins/workspace/url-here.com/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:190
Stack trace:
#0 /var/lib/jenkins/workspace/url-here.com/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php(100): Facebook\WebDriver\Remote\HttpCommandExecutor->__construct()
#1 /var/lib/jenkins/workspace/url-here.com/vendor/symfony/panther/src/ProcessManager/ChromeManager.php(75): Facebook\WebDriver\Remote\RemoteWebDriver::create()
#2 /var/lib/jenkins/workspace/url-here.com/vendor/symfony/panther/src/Client.php(117): Symfony\Component\Panther\ProcessManager\ChromeManager->start()
#3 /var/lib/jenkins/workspace/url-here.com/vendor/symfony/panther/src/Client.php(521): Symfony\Component\Panther\Client->start()
#4 /var/lib/jenkins/workspace/url-here.com/vendor/symfony/panther/src/Client.php(273): Symfony\Component\Panther\Client->get()
#5 /var/lib/jenkins/workspace" while reading response header from upstream, client: 96.244.127.121, server: url-here.com, request: "GET /googleSearch.php?q=test HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.0-fpm.sock:", host: "url-here.com", referrer: "https://url-here.com/apps/browser.html"
任何和所有的幫助將不勝感激,我一直在努力解決這個問題。如果可以的話,我會避免使用curl_init(),但不幸的是,正如您所看到的,該函式是在我的專案所依賴的庫中呼叫的。
uj5u.com熱心網友回復:
錯誤日志中的這一行表明最有可能出現的問題是:
#5 /var/lib/jenkins/workspace”同時從上游讀取回應頭,客戶端:96.244.127.121,服務器:url-here.com,請求:“GET /googleSearch.php?q=test HTTP/1.1”,上游:“fastcgi://unix: /run/php/php8.0-fpm.sock :”,主機:“url-here.com”,參考者:“https://url-here.com/apps/browser。 html"
您在這里已經安裝了 PHP 8.0,但是您已經為 PHP 8.1 安裝了 Curl。您需要檢查您的 FPM 或服務器配置。
我認為您正在使用 Nginx。如果這是正確的,那么這篇文章可能會有所幫助。具體來說,您需要查看:
- /etc/nginx/sites-available 檢查使用了哪個套接字
- /etc/php/VERSION/fpm/pool.d 檢查哪些套接字可用
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/488267.html
下一篇:值之間的Symfony約束集合
