developer tip

PHP에서 sqlite3를 활성화하는 방법은 무엇입니까?

copycodes 2020. 9. 6. 10:12
반응형

PHP에서 sqlite3를 활성화하는 방법은 무엇입니까?


Ubuntu에 PHP 용 sqlite3를 설치하려고합니다.

sqlite3 확장을 포함하도록 설치 apt-get php5-sqlite3하고 편집 php.ini했습니다.

내가 실행할 때 phpinfo();내가 얻을

SQLITE3
SQLite3 support  enabled  
sqlite3 library version  3.4.2  

위와 같이 sqlite3활성화됩니다. 그러나 사용할 때 "Class SQLite3 not found"가 표시됩니다.

 new SQLite3("database");

편집 :이 답변은 오래되었지만 수락 되었기 때문에 삭제할 수 없습니다. 정답은 Stacey Richards의 솔루션을 참조하십시오.

 sudo apt-get install php5-cli php5-dev make
 sudo apt-get install libsqlite3-0 libsqlite3-dev
 sudo apt-get install php5-sqlite3
 sudo apt-get remove php5-sqlite3
 cd ~
 wget http://pecl.php.net/get/sqlite3-0.6.tgz
 tar -zxf sqlite3-0.6.tgz
 cd sqlite3-0.6/
 sudo phpize
 sudo ./configure
 sudo make
 sudo make install
 sudo apache2ctl restart

우분투 형식 에서 찢어 졌습니다.


시험:

apt-get install php5-sqlite

그것은 나를 위해 일했습니다.


PHP7의 경우

sudo apt-get install php7.0-sqlite3

Apache를 다시 시작하십시오.

sudo apache2ctl restart

다음 링크에 연결된 포럼 스레드 의 나머지 지침 (아래에 설명 됨)이 없으면 수락 된 답변이 완전하지 않습니다 .

cd /etc/php5/conf.d

cat > sqlite3.ini
# configuration for php SQLite3 module
extension=sqlite3.so
^D

sudo /etc/init.d/apache2 restart

SQLite3 PDO 드라이버의 이름은 SQLite3가 아니라 SQLite이므로 다음을 수행 할 수 있습니다.

new SQLite("database");

SQLite2 데이터베이스의 경우 :

new SQLite2("database");

one thing I want to add , before you try to install

apt-get install php5-sqlite

or

apt-get install php5-sqlite3 

search the given package is available or not :-

 # apt-cache search 'php5'

After that you get :-

php5-rrd - rrd module for PHP 5

php5-sasl - Cyrus SASL extension for PHP 5

php5-snmp - SNMP module for php5

**php5-sqlite - SQLite module for php5**

php5-svn - PHP Bindings for the Subversion Revision control system

php5-sybase - Sybase / MS SQL Server module for php5

Here you get an idea about whether your version support or not .. in my system I get php5-sqlite - SQLite module for php5 so I prefer to install

**apt-get install php5-sqlite**

For Ubuntu 18.04 and PHP 7.2:

sudo apt install php-sqlite3


sudo apt-get install php5-cli php5-dev make

sudo apt-get install libsqlite3-0 libsqlite3-dev

sudo apt-get install php5-sqlite3

sudo apt-get remove php5-sqlite3

cd ~

wget http://pecl.php.net/get/sqlite3-0.6.tgz

tar -zxf sqlite3-0.6.tgz

cd sqlite3-0.6/

sudo phpize

sudo ./configure

That worked for me.


try this:

sudo apt-get --purge remove php5*
sudo apt-get install php5 php5-sqlite php5-mysql
sudo apt-get install php-pear php-apc php5-curl
sudo apt-get autoremove
sudo apt-get install php5-sqlite
sudo apt-get install libapache2-mod-fastcgi php5-fpm php5

In Centos 6.7, in my case the library file /usr/lib64/php/modules/sqlite3.so was missing.

yum install php-pdo 

vim /etc/php.d/sqlite3.ini
; Enable sqlite3 extension module
extension=sqlite3.so

sudo service httpd restart

Only use:

sudo apt-get install php5-sqlite

and later

sudo service apache2 restart

Depends on the version of PHP. For php7.0 the following commands work:
sudo apt-get install php7.0-sqlite3
then restart the Apache server:
sudo service apache2 restart


For Debian distributions. Nothing worked for until I added the debian main repositories on the apt sources (I don't know how were they removed): sudo vi /etc/apt/sources.list

and added

deb  http://deb.debian.org/debian  stretch main
deb-src  http://deb.debian.org/debian  stretch main

after that sudo apt-get update (you can upgrade too) and finally sudo apt-get install php-sqlite3


This will drown here, but I fixed my problems with this:

As far as I have found out, there is a faulty file in /usr/local/lib called libsqlite3.so.0 which points to libsqlite3.so.0.8.6. It's been installed through the php7.3-* packages as far as I can tell.

I renamed the file in case it was needed for something. With the command:

cd /usr/local/lib sudo mv libsqlite3.so.0 ./libsqlite3.so.0.back

But you can also just delete it: rm libsqlite3.so.0

The thread that lead me to the answer: link

This solved my problems, and I hope they solve yours as well :)

참고URL : https://stackoverflow.com/questions/948899/how-to-enable-sqlite3-for-php

반응형