If you’re like most web developers, you probably use the command line to manage your websites. And if you’re like most web developers, you probably use the php.ini file to configure your websites. But how do you find the php.ini file location from the command line? There are a few ways to find the php.ini file location from the command line:
- Use the phpinfo() function. This function prints out all of the configuration information for your PHP installation, including the location of the php.ini file. To use this function, simply type phpinfo() into your command line window and press Enter.
- Use a search engine to find information aboutphp.ini files. Google is a good place to start, as is Wikipedia (if you’re looking for more in-depth information). Simply enter “php.ini” into your search engine window and click on any of the results that come up.
- Use a text editor to open up your php.ini file and look for clues about its location. Notepad++ is a good choice for this purpose, as is vi (if you’re using Windows). Simply open up your php.ini file in one of these editors and look for lines that mention “configuration,” “file,” or “php.” If you can’t find any such lines in your own php.ini file, then it’s likely that someone else has already uploaded their own copy of this file onto their website or server - in which case it’s probably safe to copy and paste this file onto yours! ..
What this does is tell the php command-line application to run a phpinfo() and output it in text format to the shell. Then filtering it through grep to find the actual line, which will display like so:
You can, of course, always put a new php file in your web server root directory and add in the following:
And then browse to it in your browser.
phpinfo();