0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Docker + PHPでエラー:Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in ~の対処方法

Last updated at Posted at 2021-04-20

PHPのバージョンアップに伴い、mysqli_connect()がエラーに!!

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in ~

書き方はあっているはず。
なのにどうして!!??

「mysqliをインストールしてないんですよ」
「え、それだけ。。。」
「Dockerにmysqliをインストールしてごらん」

Dockerfileを編集しよう

「PHPのDockerfileに下記を追加してみ」

Dockerfile
  RUN docker-php-ext-install mysqli && \
  docker-php-ext-enable mysqli 

「追加しました」
「じゃあ、あとは$docker-compose build し直して」

コマンド
$ docker-compose build
$ docker-compose up -d

おおおおお!! エラーがなくなりました✨

嘘です、別のエラーが表示されました。。。

mysqli_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known

つづく。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?