skip to Main Content

I got this error. Any idea?

Thank you.

Error:

PHP Fatal error:  Uncaught Error: Undefined constant "CURLOPT_TCP_FASTOPEN"

OS:

CentOs 7.x

Version:

3.10.0-1160.76.1.el7.x86_64

$curl –tcp-fastopen -O http://google.com

curl: option --tcp-fastopen: is unknown
curl: try 'curl --help' or 'curl --manual' for more information

$ php -v

PHP 8.1.12 (cli) (built: Oct 25 2022 17:30:00) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.12, Copyright (c) Zend Technologies

$cat /proc/sys/net/ipv4/tcp_fastopen

3

PHP has been installed using:

sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php81
sudo yum repolist
sudo yum -y install php php-{cli,mbstring,curl,json}

php.ini

cURL support => enabled
cURL Information => 7.29.0
Age => 3
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => Yes
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => No
SSL => Yes
SSPI => No
TLS-SRP => No
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host => x86_64-redhat-linux-gnu
SSL Version => NSS/3.53.1
ZLib Version => 1.2.7
libSSH Version => libssh2/1.8.0

2

Answers


  1. You are using CentOS 7 which is more than 8 years old, and is close to its end of life (in June 2024).

    I heartily recommend to use a more recent distribution version (8 or 9), especially for modern features.

    CURLOPT_TCP_FASTOPEN was introduced in curl 7.49

    • EL-7 have 7.19
    • EL-8 have 7.61
    • EL-9 have 7.76

    So you cannot fix this error in EL-7 without rebuilding nearly everything.

    Login or Signup to reply.
  2. CURLOPT_TCP_FASTOPEN requires libcurl 7.49.0 or newer, while your PHP is compiled against libcurl 7.29.0. upgrade your libcurl and compile php again.

    maybe try

    git clone -b 'OpenSSL_1_1_1k' --single-branch --depth 1 https://github.com/openssl/openssl
    cd openssl
    ./config
    make -j $(nproc)
    mkdir lib
    cp *.a lib;
    cd ..
    git clone -b 'curl-7_76_1' --single-branch --depth 1 https://github.com/curl/curl.git
    cd curl
    ./buildconf
    LDFLAGS="-static" ./configure --with-ssl=$(realpath ../openssl) --enable-static
    make -j $(nproc)
    cd ..
    git clone -b 'PHP-8.1' --single-branch --depth 1 'https://github.com/php/php-src.git'
    cd php-src;
    ./buildconf;
    ./configure --with-curl=$(realpath ../curl)
    make -j $(nproc)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search