Cannot enable php-curl on Ubuntu 18.04 & PHP 7.2












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:4nStack 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?










share|improve this question





























    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:4nStack 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?










    share|improve this question



























      1












      1








      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:4nStack 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?










      share|improve this question
















      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:4nStack 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?







      18.04 apache2 php curl






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 7 at 17:56







      MathewH

















      asked Feb 7 at 17:12









      MathewHMathewH

      216




      216






















          1 Answer
          1






          active

          oldest

          votes


















          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.






          share|improve this answer
























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1116448%2fcannot-enable-php-curl-on-ubuntu-18-04-php-7-2%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            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.






            share|improve this answer




























              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.






              share|improve this answer


























                1












                1








                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 7 at 18:26









                MathewHMathewH

                216




                216






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1116448%2fcannot-enable-php-curl-on-ubuntu-18-04-php-7-2%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Human spaceflight

                    Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

                    File:DeusFollowingSea.jpg