PHP 7 RC3: How to install missing MySQL PDO

后端 未结 12 751
暗喜
暗喜 2020-12-04 11:54

I am trying to setup webserver with PHP 7 RC3 + Nginx on Ubuntu 14.04 (for test purposes).

I installed Ubuntu in Vagrant using

相关标签:
12条回答
  • 2020-12-04 12:22

    I'll start with the answer then context NOTE this fix was logged above, I'm just re-stating it for anyone googling.

    1. Download the source code of php 7 and extract it.
    2. open your terminal
    3. swim to the ext/pdo_mysql directory
    4. use commands:

      phpize

      ./configure

      make

      make install (as root)

    5. enable extension=mysqli.so in your php.ini file

    This is logged as an answer from here (please upvote it if it helped you too): https://stackoverflow.com/a/39277373/3912517

    Context: I'm trying to add LimeSurvey to the standard WordPress Docker. The single point holding me back is "PHP PDO driver library" which is "None found"

    php -i | grep PDO                                                                                  
    PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_odbc' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_odbc (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_odbc: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_odbc.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/pdo_odbc.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    PHP Warning:  Module 'mysqli' already loaded in Unknown on line 0
    PDO
    PDO support => enabled
    PDO drivers => sqlite
    PDO Driver for SQLite 3.x => enabled
    

    Ubuntu 16 (Ubuntu 7.3.0)

    apt-get install php7.0-mysql
    

    Result:

    Package 'php7.0-mysql' has no installation candidate
    

    Get instructions saying all I have to do is run this:

    add-apt-repository -y ppa:ondrej/apache2
    

    But then I get this:

    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 223: ordinal not in range(128)
    

    So I try and force some type of UTF: LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/apache2 and I get this: no valid OpenPGP data found.

    Follow some other instructions to run this: apt-get update and I get this: Err:14 http://ppa.launchpad.net/ondrej/apache2/ubuntu cosmic/main amd64 Packages 404 Not Found Err:15 http://ppa.launchpad.net/ondrej/php/ubuntu cosmic/main amd64 Packages 404 Not Found and - I think because of that - I then get:

    The repository 'http://ppa.launchpad.net/ondrej/apache2/ubuntu cosmic Release' does not have a Release file.
    

    By this stage, I'm still getting this on apt-get update:

    Package 'php7.0-mysql' has no installation candidate.
    

    I start trying to add in php libraries, got Unicode issues, tried to get around that and.... you get the idea... whack-a-mole. I gave up and looked to see if I could compile it and I found the answer I started with.

    You might be wondering why I wrote so much? So that anyone googling can find this solution (including me!).

    0 讨论(0)
  • 2020-12-04 12:23

    Since eggyal didn't provided his comment as answer after he gave right advice in a comment - i am posting it here: In my case I had to install module php-mysql. See comments under the question for details.

    0 讨论(0)
  • 2020-12-04 12:25

    I had, pretty much, the same problem. I was able to see that PDO was enabled but I had no available drivers (using PHP 7-RC4). I managed to resolve the issue by adding the php_pdo_mysql extension to those which were enabled.

    Hope this helps!

    0 讨论(0)
  • 2020-12-04 12:28

    First install php-mysql

    sudo apt-get install php7.0-mysql
    //change the version number based on the php version
    

    then enable the module

    sudo phpenmod pdo_mysql
    

    and restart apache

    sudo service apache2 restart 
    
    0 讨论(0)
  • 2020-12-04 12:31

    Had the same issue, resolved by actually enabling the extension in the php.ini with the right file name. It was listed as php_pdo_mysql.so but the module name in /lib/php/modules was called just pdo_mysql.so

    So just remove the "php_" prefix from the php.ini file and then restart the httpd service and it worked like a charm.

    Please note that I'm using Arch and thus path names and services may be different depending on your distrubution.

    0 讨论(0)
  • 2020-12-04 12:36

    On ubuntu 18.04 following works for me

    type this in your terminal

    For php7.3

    sudo apt-get install php7.3-gd php7.3-mysql
    

    For php7.0

    sudo apt-get install php7.0-gd php7.0-mysql
    

    For php5

    sudo apt-get install php5-gd php5-mysql
    
    0 讨论(0)
提交回复
热议问题