SoftwareAndOutsourcing
SoftwareAndOutsourcing

Reputation: 140

Enable disabled function only for cli

I'm doing some scripting using php, and I need the exec command.which is disabled in disable_functions in php.ini. Is possible to enable it for the command line and keep it disabled for the webserver?

Upvotes: 1

Views: 2108

Answers (1)

Fluffeh
Fluffeh

Reputation: 33532

Sure is, you simply create a second .ini file that is used by the CLI which you can then really simply call via the command to start your PHP script like this:

php -c /home/username/public_html/php.ini /home/username/public_html/myscript.php

This then forces PHP to use the second .ini file and you can enable/disable whatever you like. I would also recommend changing the default timeout value so that your longer running scripts don't time out.

You can also simply use phpinfo() in a test script from the CLI to ensure that you are using the correct file.

Upvotes: 4

Related Questions