2016-02-27 106 views
0

我正在使用NGINX和PHP-FPM爲SQLite作爲我的數據庫提供Laravel 5.1 Web應用程序。Laravel 5.1找不到SQLite驅動程序

但是,當我的Web應用程序嘗試創建新用戶(從瀏覽器)時,我收到異常PDOException in Connector.php line 55: could not find driver。想通我忘了安裝/啓用一些源碼包......但是:

我覈實,SQLite的安裝:dpkg --get-selections | grep sqlite如果源碼與php -m啓用

libsqlite0     install 
libsqlite3-0:amd64   install 
php5-sqlite     install 
sqlite3      install 

然後檢查:

[PHP Modules] 
bcmath 
bz2 
calendar 
Core 
ctype 
curl 
date 
dba 
dom 
ereg 
exif 
fileinfo 
filter 
ftp 
gd 
gettext 
gmp 
hash 
iconv 
imagick 
intl 
json 
libxml 
mbstring 
mhash 
openssl 
pcntl 
pcre 
PDO 
pdo_sqlite 
Phar 
posix 
readline 
Reflection 
session 
shmop 
SimpleXML 
soap 
sockets 
SPL 
sqlite3 <--- there it is! 
standard 
sysvmsg 
sysvsem 
sysvshm 
tokenizer 
wddx 
xml 
xmlreader 
xmlwriter 
Zend OPcache 
zip 
zlib 

[Zend Modules] 
Zend OPcache 

確保我正確設置了權限:sudo chmod 775 database.sqlite

也試過運行php artisan tinker,看看我能重現錯誤的服務器上:

\App\User::firstOrCreate(array('id' => 'afasdfadsf', 'name' => 'Matthew Mitchener', 'email' => '[email protected]'));

輸出:

App\User {#719 
    id: "afasdfadsf", 
    name: "Matthew Mitchener", 
    email: "[email protected]", 
    updated_at: "2016-02-27 16:01:25", 
    created_at: "2016-02-27 16:01:25", 
} 

所以它似乎很好地工作。我以root用戶身份運行它,也許這是問題的一部分?我什麼都沒有,我可以嘗試。

Halp! :(

而且,這裏是整個堆棧跟蹤:

in Connector.php line 55 
at PDO->__construct('sqlite:/var/www/soqool/database/database.sqlite', null, null, array('0', '2', '0', false, false)) in Connector.php line 55 
at Connector->createConnection('sqlite:/var/www/soqool/database/database.sqlite', array('driver' => 'sqlite', 'database' => '/var/www/soqool/database/database.sqlite', 'prefix' => '', 'name' => 'sqlite'), array('0', '2', '0', false, false)) in SQLiteConnector.php line 37 
at SQLiteConnector->connect(array('driver' => 'sqlite', 'database' => '/var/www/soqool/database/database.sqlite', 'prefix' => '', 'name' => 'sqlite')) in ConnectionFactory.php line 60 
at ConnectionFactory->createSingleConnection(array('driver' => 'sqlite', 'database' => '/var/www/soqool/database/database.sqlite', 'prefix' => '', 'name' => 'sqlite')) in ConnectionFactory.php line 49 
at ConnectionFactory->make(array('driver' => 'sqlite', 'database' => '/var/www/soqool/database/database.sqlite', 'prefix' => ''), 'sqlite') in DatabaseManager.php line 175 
at DatabaseManager->makeConnection('sqlite') in DatabaseManager.php line 67 
at DatabaseManager->connection(null) in Model.php line 3224 
at Model::resolveConnection(null) in Model.php line 3190 
at Model->getConnection() in Model.php line 1870 
at Model->newBaseQueryBuilder() in Model.php line 1813 
at Model->newQueryWithoutScopes() in Model.php line 1787 
at Model->newQuery() in Model.php line 3435 
at Model->__call('firstOrCreate', array(array('id' => '005o0000000yosIAAQ', 'name' => 'Matthew Mitchener', 'email' => '[email protected]'))) 
at User->firstOrCreate(array('id' => '005o0000000yosIAAQ', 'name' => 'Matthew Mitchener', 'email' => '[email protected]')) 
at call_user_func_array(array(object(User), 'firstOrCreate'), array(array('id' => '005o0000000yosIAAQ', 'name' => 'Matthew Mitchener', 'email' => '[email protected]'))) in Model.php line 3451 
at Model::__callStatic('firstOrCreate', array(array('id' => '005o0000000yosIAAQ', 'name' => 'Matthew Mitchener', 'email' => '[email protected]'))) in SalesforceAuthentication.php line 33 
at User::firstOrCreate(array('id' => '005o0000000yosIAAQ', 'name' => 'Matthew Mitchener', 'email' => '[email protected]')) in SalesforceAuthentication.php line 33 
at SalesforceAuthentication->callback() in AuthorizeController.php line 25 
at AuthorizeController->callback() 
at call_user_func_array(array(object(AuthorizeController), 'callback'), array()) in Controller.php line 256 
at Controller->callAction('callback', array()) in ControllerDispatcher.php line 164 
at ControllerDispatcher->call(object(AuthorizeController), object(Route), 'callback') in ControllerDispatcher.php line 112 
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114 
at ControllerDispatcher->callWithinStack(object(AuthorizeController), object(Route), object(Request), 'callback') in ControllerDispatcher.php line 69 
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\AuthorizeController', 'callback') in Route.php line 203 
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134 
at Route->run(object(Request)) in Router.php line 708 
at Router->Illuminate\Routing\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 
at Pipeline->then(object(Closure)) in Router.php line 710 
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 675 
at Router->dispatchToRoute(object(Request)) in Router.php line 635 
at Router->dispatch(object(Request)) in Kernel.php line 236 
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50 
at VerifyCsrfToken->handle(object(Request), object(Closure)) 
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49 
at ShareErrorsFromSession->handle(object(Request), object(Closure)) 
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62 
at StartSession->handle(object(Request), object(Closure)) 
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) 
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59 
at EncryptCookies->handle(object(Request), object(Closure)) 
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44 
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) 
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) 
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 
at Pipeline->then(object(Closure)) in Kernel.php line 122 
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87 
at Kernel->handle(object(Request)) in index.php line 54 

運行ls -la /etc/php5/fpm/conf.d

total 8 
drwxr-xr-x 2 root root 4096 Feb 27 12:27 . 
drwxr-xr-x 4 root root 4096 Feb 27 12:18 .. 
lrwxrwxrwx 1 root root 32 Feb 24 21:46 05-opcache.ini -> ../../mods-available/opcache.ini 
lrwxrwxrwx 1 root root 28 Feb 24 21:46 10-pdo.ini -> ../../mods-available/pdo.ini 
lrwxrwxrwx 1 root root 29 Feb 24 21:53 20-curl.ini -> ../../mods-available/curl.ini 
lrwxrwxrwx 1 root root 27 Feb 24 21:54 20-gd.ini -> ../../mods-available/gd.ini 
lrwxrwxrwx 1 root root 28 Feb 24 21:53 20-gmp.ini -> ../../mods-available/gmp.ini 
lrwxrwxrwx 1 root root 32 Feb 24 21:54 20-imagick.ini -> ../../mods-available/imagick.ini 
lrwxrwxrwx 1 root root 29 Feb 24 21:53 20-intl.ini -> ../../mods-available/intl.ini 
lrwxrwxrwx 1 root root 29 Feb 24 21:46 20-json.ini -> ../../mods-available/json.ini 
lrwxrwxrwx 1 root root 35 Feb 27 12:27 20-pdo_sqlite.ini -> ../../mods-available/pdo_sqlite.ini 
lrwxrwxrwx 1 root root 33 Feb 24 21:46 20-readline.ini -> ../../mods-available/readline.ini 
lrwxrwxrwx 1 root root 32 Feb 27 12:27 20-sqlite3.ini -> ../../mods-available/sqlite3.ini 

運行:cat /etc/php5/fpm/conf.d/10-pdo.ini

; configuration for php PDO module 
; priority=10 
extension=pdo.so 

回答

1

看來你有CLI不同的php.ini和web。你應該添加pdo-sqllite驅動程序到php.ini for web和resta rt Apache或php-fpm。

嘗試創建簡單的文件:

<?php 
echo php_info(); 

,找到php.ini的路徑。

+0

良好的通話,是這樣的: '配置文件(php.ini中)路徑=>在/ etc/PHP5/cli' '加載的配置文件=>在/ etc/PHP5/CLI/php.ini' 對於網頁: '配置文件(php.ini)路徑/ etc/php5/fpm' '加載配置文件/ etc/php5/fpm/php.ini' –

+0

您能顯示異常消息,而不是堆棧跟蹤嗎? –

+0

'Connector.php中的PDOException異常第55行:無法找到驅動程序' –

0

問題原來是一些模塊沒有被php-fpm加載。

重新啓動fpm service php5-fpm restart不會加載它們。於是我用reboot重新啓動整個服務器,並加載它們。

相關問題