What’s different from php.ini in Apache2 and CLI?

Asked

Viewed 29 times

0

In my php versions, I own these two folders (apache2 and CLI) and both contain php.ini. What’s the difference between each? When I know which I can or should change?

1 answer

0


One is specifically to be used for apache and another for when you will run php via terminal, which need have nothing to do with web, for example run composer or execute CRON that calls scripts .php, would be terminal.

This is something more of how the repositories of some distros work, it’s not all distro that will follow this path.

The utility of having files php.ini separate is that for scripts .php terminal/cmd facing you will be able to release more sensitive features, such as allowing greater memory consumption, something that in a web server is ideal to limit to prevent "poorly done" php scripts from causing unexpected problems.

For example if in terminal/cmd you know you will not use the database extensions (through the PDO, mysqli, pgsql, etc Apis) so in php.ini specific for CLI it is almost certain that you can disable them, except for if you are calling an external PHP script via CRON or via functions such as exec(), passthru(), shell_exec(), proc_open() and popen() that need to do some database operation.

Remember that as I said, create different files php.ini is something practically customizable from each distro (more specifically repository), even you can customize on your own (depending on the way your operating system works).

  • What about the Web, where are the library settings located? Libraries are enabled by the 'Extension' line within php.ini for the web as well?

  • @Reginaldev no, you don’t need all extensions, you can turn off the mysql extension on the site that uses postgres and turn off the postgres extension on the site that uses mysql, unless you use Migration), so you can usually shut down all database modules on it.

  • ps: when I refer to the database module/extension, I am not talking about the banks themselves, because usually the banks are in locations totally different from the scripts, what the extensions allow is to access these banks (remotely or locally), are "Apis"

  • And how do I do that? Apparently I’m changing php.ini but it has no effect, even though I’m renouncing the apache2 service. There is another way to disable modules?

  • @Reginaldev ai is very specific, because if you edited the correct php.ini from apache and restarted apache with the correct command then it should work, but there’s no way I know what you’re using ... because there are many linux distros (probably much more) with different ways to work, there are alternative ways to repositories to use PHP, for example you may have used Xampp instead of using the repository. There is no standard for this, so there’s no way I know what your development environment looks like.

  • I recommend you ask a new detailed question.

  • In fact, if you have installed via archive (as in Debian with apt-get) I recommend asking at https://serverfault.com @Reginaldev

  • @Reginaldev ps: I checked the details of Phpinidir and I think q in virtualhost that doesn’t work, then I confirm, but it is almost certain that it is only possible to have a php.ini in apache2handler, in fastcgi I’m not sure, but anyway this is something else, which has nothing to do with the CLI. Maybe later I’ll make a response dedicated to fastcgi and apache2handler about php.ini.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.