I installed(manually) Apache and PHP. I activated the curl extension from php.ini and It's working fine in PHP-CLI, but when I access PHP through browser with the help of Apache, curl(and any other) extension giving me errors that "{extension_function} is undefined"
PHP 7.2-64bit
Apache 2.4
// php.ini
extension_dir = "/server/php/ext"
...
extension=bz2
extension=curl
extension=fileinfo
;extension=gd2
;extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=interbase
;extension=ldap
;extension=mbstring
;extension=exif ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=odbc
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
;extension=pgsql
;extension=shmop
// httpd.conf
LoadModule php7_module "/server/php/php7apache2_4.dll"
<IfModule php7_module>
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
PHPIniDir "/server/php"
</IfModule>
Update
I'm testing using this var_dump(function_exists('curl_init'));
line of code ...
when I run this line from php-cli, It's returning true.
When I run this line from a php file using browser, It's returning false.
Solved
- I used absolute paths everywhere(no relative path)(used forward slashes)
- Added PHP to environment variables. I don't know why, but without this extensions aren't loading. I think php7 module for Apache requires php in environment.
- Restarted the computer(Apache restart won't work)
I hope someone will find this helpful.
Thank you for the help.