The objective of this article is to learn how to find location of loaded php.ini. file.

In this tutorial you will learn:
  • How to find location of php.ini from command line
  • How to find location of php.ini by using the phpinfo() function
Find the location of php.ini on Ubuntu 20.04 Focal Fossa Linux
Find the location of php.ini on Ubuntu 20.04 Focal Fossa Linux

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed or upgraded Ubuntu 20.04 Focal Fossa
Software Apache, Nginx, PHP, PHP-FPM
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

Location of php.ini on Ubuntu 20.04 step by step instructions

  1. Create a file called phpinfo.php within your web-server's root directory eg. /var/www/html/ with the following content:
    <?php
    
    // Show all information, defaults to INFO_ALL
    phpinfo();
    
    ?>?

  2. SUBSCRIBE TO NEWSLETTER
    Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


  3. Navigate your web browser to the URL location http://SERVER-HOST-OR-IP/phpinfo.php. Search the page for the loaded php.ini configuration file.
  4. Alternatively execute the following command to locate the loaded php.ini configuration file for the command line (cli) php command:
    php --ini | grep Loaded
    Loaded Configuration File:         /etc/php/7.3/cli/php.ini
    
    Please, note that the above php.ini file location is used by phpcommand. For the Apache web-server the above path will translate to:
    /etc/php/7.3/apache2/php.ini
    
    For Nginx or Apache with PHP-FPM the path will most likely be:
    /etc/php/7.3/fpm/php.ini
    
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.