MySQLi not found dockerized php

前端 未结 4 1234
南旧
南旧 2021-01-04 05:06

I\'m trying to dockerize my website. I\'ve got Nginx and PHP up and running and it\'s working find except I can\'t connect to a db. When the page is loaded I get the error:<

相关标签:
4条回答
  • 2021-01-04 05:46

    It looks like you don't have the MysqlI extension enabled in your php.ini. If enabled, you should see a section mysqli in your phpinfo.

    More info on enabling the extension can be found here: Fatal error: Class 'MySQLi' not found

    0 讨论(0)
  • 2021-01-04 05:49

    works for me:

    inside php container:

    docker-php-ext-install mysqli
    
    apachectl restart
    
    • docker images: mysql, php:7.2.30-apache

    https://github.com/docker-library/php/issues/391

    0 讨论(0)
  • 2021-01-04 05:51

    i had similar issue with
    php:7-apache image, which by default will not have mysqli installed
    you can verify this inside the container

    $ docker exec -it <phpcontainerid> bash  
    

    inside the docker container bash terminal

    # docker-php-ext-enable mysqli
    

    if mysqli is not installed which you will come to know from the output of above command

    # docker-php-ext-install mysqli
    

    then i commited this change so the same image

    $ docker commit -p <phpcontainerid> <new or same image name>
    
    0 讨论(0)
  • 2021-01-04 06:11

    You need to enable the php extension in your Dockerfile:

    FROM php:7
    RUN docker-php-ext-install mysqli
    

    There is no need to touch php.ini.

    0 讨论(0)
提交回复
热议问题