I search the path where the php.ini file is located in our Linux Ubuntu server, and I found many php.ini when executing the command find / -name php.ini
. So how to know exactly from a php script web page where the php.ini is located ?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
You have to use the php method
php_ini_loaded_file
(only after php 5.2.4)php website example:
Source: php site
just put a file like this:
Then look for
you'll see full path for php.ini file
Note that the configuration loaded for PHP when it's being used on the console is different from the configuration for the web process. Most PHP installations would come with a php.ini for apache and another for CLI.
To know which configuration file is used for the console commands, use
To know which configuration file is used for the web processes, follow these steps
<?php phpinfo(); ?>
Ctrl+F
and search for "Configuration File"You can use php_ini_loaded_file()
Taken from php.net:
You may also want to check php_ini_scanned_files()
Also, you should note that if you run a PHP script from CLI, it's possible that a different
php.ini
file will be used than if a server (ie nginx or apache) runs it.Other options:
php -i|grep 'php.ini'
info.php
that contains<?php phpinfo();
in the webroot, and run it in your browserFor the webserver-SAPIs use
phpinfo()
Here's some sample output:
Create a simple page and it will be listed there!