Problems with PHP, CLI, PDO in LAMP stackscript configuratio

Hi, I have a problem with my linode server configuration, after installing a lamp with Ubuntu 12.04 lamp stackscript.

When I run a php script with apache php, all its ok, but when I run this script with PHP CLI, I always get this error:

php -qn -d memory_limit=128M script.php

Fatal error: Class 'PDO' not found in script.php on line 51

But PDO is enabled in all php runtimes configurations (apache and cli).

If I run:

php –ini

I get:

Configuration File (php.ini) Path: /etc/php5/cli

Loaded Configuration File: /etc/php5/cli/php.ini

Scan for additional .ini files in: /etc/php5/cli/conf.d

Additional .ini files parsed: /etc/php5/cli/conf.d/curl.ini,

/etc/php5/cli/conf.d/gd.ini,

/etc/php5/cli/conf.d/mcrypt.ini,

/etc/php5/cli/conf.d/mysql.ini,

/etc/php5/cli/conf.d/mysqli.ini,

/etc/php5/cli/conf.d/pdo.ini,

/etc/php5/cli/conf.d/pdo_mysql.ini

So, php CLI has pdo.ini loaded.

Any suggestion?

It could be a permissions issue, related with pdo.so module?

thanks in advance

4 Replies

What do you get when you run a script with phpinfo() in it from the command line? Are the PDO entries in there?

What's in /etc/php5/cli/conf.d/mysqli.ini, pdo.ini and pdo_mysql.ini?

Thanks for your answer: phpinfo() returns this in relation to PDO:

php -r "phpinfo();"

PDO

PDO support => enabled

PDO drivers => mysql

pdo_mysql

PDO Driver for MySQL => enabled

Client API version => 5.5.37

Directive => Local Value => Master Value

pdomysql.defaultsocket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock

mysqli.ini contains:

extension=mysqli.so

pdo.ini:

extension=pdo.so

pdo_mysql.ini:

extension=pdo_mysql.so

Thanks again

Sorry, my fault

php -qn -d memory_limit=128M script.php

-n tells php runtime to not use ini file.

Thank you for your time

azabala, I'm glad it worked out.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct