1

So Apache has its own service account, and when i load a page from the URL, on my browser, it loads runs the page with the service account and it works fine, no errors.

But when i do php -q "LOCAL PATH TO FILE", on root account from the terminal over SSH i get errors such as:

For MySQLi = "Call to undefined function mysqli_connect()"

For MySQL = "mysql_connect(): No such file or directory"

Now the thing is, it does work fine if i load the page from my browser, just not when i run it from terminal.

I need to be able to run it from the terminal because of CronJobs.

This originally worked, but im not sure why it has stopped working, apparently i need to install a PHP module to get it to work, but im not sure because im having a hard time finding results that are the same situation as my issue.

I am using CentOS.

Thanks

14
  • 3
    stackoverflow.com/questions/11585399/… Commented Jan 2, 2013 at 16:38
  • i tried that, it doesnt work, ive already installed php-mysqli Commented Jan 2, 2013 at 16:47
  • 2
    Often the web server and the CLI SAPI use different ini files. Run php -i from the command line, verify that if shows MySQLi as being enabled, and if (when) it is not, go to the ini file identified near the top of the output and enable it. Commented Jan 2, 2013 at 17:03
  • 1
    @Headchopperz You can specify the ini file that is loaded at call time - add -c /path/to/php.ini to your command line. Commented Jan 2, 2013 at 17:33
  • 1
    Probably CLI is using different php.ini. Just find it and turn on mysqli. Commented Jan 2, 2013 at 18:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.