问题
I am using xampp
server for PHP
development and want to edit the php.ini
file; where can I locate it?
回答1:
For Windows, you can find the file in the C:\xampp\php\php.ini
-Folder (Windows) or in the etc
-Folder (within the xampp-Folder).
Under Linux, most distributions put lampp under /opt/lampp
, so the file can be found under /opt/lampp/etc/php.ini
.
It can be edited using a normal Text-Editor.
Clarification:
Xampp
(X (for "some OS"), Apache, MySQL, Perl, PHP)Lampp
(Linux, Apache, MySQL, Perl, PHP)
in this context, they can be substituted for one another.
回答2:
Write the following inside phpini_path.php
( or AnyNameAsYouLike.php
) and run it in the browser.
<?php phpinfo();?>
Among various other parameters you'll get Loaded Configuration File
parameter which value is the path of php.ini
on the server.
The location of php.ini
depends on server operating system:
Windows (With Xampp Installation):
/xampp/php/php.ini
macOS, OS X:
/private/etc/php.ini
Linux:
/etc/php.ini
/usr/bin/php5/bin/php.ini
/etc/php/php.ini
/etc/php5/apache2/php.ini
回答3:
If you have multiple php-versions (xampp etc) running, I find the easiest is to use:
php --ini
from the command line. In windows: either after you click Shell
in xampp, or directly in the regular cmd
to find the "global" version of php. With global I mean the version referenced to by your environment variables.
回答4:
In MacOS : /Applications/XAMPP/xamppfiles/etc/php.ini
回答5:
Put a script somewhere in your document root
<?php
phpinfo();
Among others the output of the function will tell you which php.ini
s are parsed before the script got executed.
回答6:
Run Xampp server.
Go to http://localhost which will open up xampp dashboard.
Go to PHPInfo link in the top navigation bar.
--- or directly type following url in the browser after run the XAMPP http://localhost/dashboard/phpinfo.php
This will open up php info page. There you can find "Loaded Configuration File /opt/lampp/etc/php.ini" which is the php.ini location.
回答7:
my OS is ubuntu, XAMPP installed in /opt/lampp
, and I found php.ini in /opt/lampp/etc/php.ini
回答8:
If you have been using different installers, you may well end up with more that one php.ini file on your hdd, which could affect your sanity after a while.
Search your hdd for 'php.ini' just in case there is more than one.
Another sanity-saving move is to remember to always restart your server (apache) after altering a value in php.ini.
回答9:
i'm using xampp with PHP 7. you can trying looking for php.ini in
/etc/php/7.0/apache2
回答10:
in my case it is present as "php.ini-development" and "php.ini-production" in php folder
回答11:
Am running LAMP
on Debian and mine is in:
/etc/php/7.0/apache2/php.ini
回答12:
In the documentation http://www.apachefriends.org/en/xampp-windows.html (Configuration files section, near the bottom of the page): \xampp\php\php.ini
回答13:
as KingCrunch pointed out, using phpinfo you can see what config file is in action in the "Loaded Configuration File" row. in my case in was in C:\xampp\apache\bin note that there is a php.ini also in C:\xampp\php which seems to be redundant and irrelevant
回答14:
I've always found the easiest way is php -i
and filtering down.
*nix (including MacOS):
php -i | grep "Loaded Configuration File"
Windows:
php -i | findstr /C:"Loaded Configuration File"
Of course this assumes your CLI environment is using the same PHP binaries as your actual web server.
You can always check that to be sure using which php
in *nix and where php
in Windows.
回答15:
I’ve run into the need while running on PhpStorm on my Mac. Follow the orange text.
来源:https://stackoverflow.com/questions/6185319/how-to-locate-the-php-ini-file-xampp