Where is php.ini file located?

When you are working with various flavors of Linux servers, you may not know where php.ini file is located. The php.ini file is a php configuration file that is used to customize the behaviors and features of the php scripting language. A php.ini file is placed in different directory location of a server depending on the flavor and version of the Linux server you're working with. Here are a few ways to determine where the php.ini configuration is located.

If you have an access to shell, you may use the following Linux commands to locate the php.ini file.

%> whereis php
php: /usr/bin/php /etc/php.ini /etc/php.d /usr/lib/php /usr/include/php /usr/share/man/man1/php.1.gz

%> php -i |grep php.ini

# Or, you may use a brute force "find" command to search the entire filesystem
%> find / -type f -name "php.ini" -print

You may also create a php info file to find php configuration of a server. Create a file called "phpinfo.php", and add the following content:

The phpinfo() not only show you where php.ini file is located, but also reveal details of your server and php configurations as well as installed modules and their versions.

Several common locations of php.ini include the following directories.

/etc/php.ini (Red Hat/Centos)

/etc/php/php.ini
/etc/php5/php.ini

/etc/php5/apache2/php.ini (SuSE)

/usr/bin/php5/bin/php.ini

/usr/local/Zend/php.ini
/usr/local/lib/php.ini

Comments

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.