1

So right now, i am attempting to enable php-curl within my apache2 server on Ubuntu 18.04 to allow an iframe to display an external site page. i have been using methods to attempt this that i have found documented in several places:

StackOverflow: How do I install the ext-curl extension with PHP 7?

StackOverflow: install cURL in php 7 (ubuntu14.04)

LinuxConfig.org: How to enable and disable PHP curl module with Apache on Ubuntu Linux

No matter what i seem to do, i cannot get anything sort of curl-related commands to work within php, which is very frustrating. i have ensured that i have used sudo apt-get install curl php7.2-curl which installed without issue, and have then restarted the apache service using sudo service apache2 restart. I have tried to enable the extension in the php.ini using extension=php_curl.dll, and also extension=curl, with no luck. If i try the code given on linuxconfig.org to check the curl module state, it says its disabled.

If i try running my php code, i find in my logs:

PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /var/www/html/inc.redirect.php:4\nStack trace:\n#0 {main}\n thrown in /var/www/html/inc.redirect.php on line 4

The code in my 'inc.redirect.php' file is as follows:

<?php
if (isset($_GET['url'])) {
    $url = $_GET['url'];
    $ch = curl_init();
    $timeout = 10;
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    echo $data;
}
?>

What am i doing wrong/missing?

UPDATE: looking in the apache2 error.log when i restart the service, i see the following:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/curl.so' - /usr/lib/php/20160303/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0

Still attempting to dig more into this, and it appears that the curl.so file its looking for is located in '/usr/lib/php/20170718'. What do i have to do to change the php config to look in the proper directory?

1

Found the issue.

What was happening was I had both php7.1 and php7.2 enabled within apache2. had to run sudo a2dismod php7.1, restart apache, and afterwards I was able to load my inc.redirect.php page without errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.