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
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
So you cannot fix this error in EL-7 without rebuilding nearly everything.
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