LoginSignup
2
1

More than 5 years have passed since last update.

PHPで「Fatal error: Class 'mysqli' not found」と出た時の対処法

Posted at

PHPでmysqliを使おうとした時、こんなエラーが表示された。

Fatal error: Class 'mysqli' not found

どうやら、mysqliモジュールが有効になってないのが原因らしい。

php.iniを編集する

php.iniを編集し、モジュールを有効化する。

$ vim /usr/local/lib/php.ini

先頭のセミコロンを消す

;extension=php_mysqli.dll

extension=php_mysqli.dll

しかし、また同じエラーが出た。

mysqliをインストール

そもそもmysqliモジュールをインストールしてなかったのでphpを再インストール
phpのソースが置いてある場所に行き、configureする時に--width-mysqliというオプションをつけるとインストールできる。

$ cd /usr/local/src/php-5.6.0
$ make clean
$ ./configure --enable-mbstring --with-apxs2=/usr/local/apache2/bin/apxs --enable-pdo --with-gd --with-png-dir=/usr/local --with-jpeg-dir=/usr/local --with-mysql --with-mysqli
$ make
$ make install

参考
http://php.net/manual/ja/mysqli.installation.php

2
1
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
2
1