Как найти php ini centos

Дано: vps на centos , vesta panel по умолчанию со всем что с ней идет.
+ я чуть чуть больше нуба в администрировании.

Изначально, php.ini в centos хранится в /etc/php.ini, ведь так? Я задал там необходимые настройки, в том числе максимальное время выполнения скрипта и параметр timezone.
Разумеется, обновил apache запросом — service httpd restart .

Но при выводе phpinfo() присутствует строка:
Loaded Configuration File /etc/php.ini
Она ведь ссылает на текущий php ini?

Но в нем совершенно иные данные по сравнению с тем, что я сохранял в /etc/php.ini
max_execution_time 30 30

Так вот вопрос, где копать php.ini ?

In your terminal/console (only Linux, in windows you need Putty)

ssh user@ip
php -i | grep "Loaded Configuration File"

And it will show you something like this Loaded Configuration File => /etc/php.ini.

ALTERNATIVE METHOD

You can make a php file on your website, which run: <?php phpinfo(); ?>, and you can see the php.ini location on the line with: «Loaded Configuration File».

Update
This command gives the path right away

cli_php_ini=php -i | grep /.+/php.ini -oE  #ref. https://stackoverflow.com/a/15763333/248616
    php_ini="${cli_php_ini/cli/apache2}"   #replace cli by apache2 ref. https://stackoverflow.com/a/13210909/248616

How can we find the default configuration files for the PHP packages in CentOS Linux?

By using the RPM command we can query a package to find all of its associated configuration files. Failing that we can use the find command to search the file system for these files, as we will see here.

Finally we’ll cover how we can use a phpinfo file to show us which configuration file is in use.

RPM Query Configuration Files

The options we will use with the RPM command are -q to query a package, and -c which will list the configuration files that are part of the package. As shown below we have run RPM with the -qc options on the php-common package, which is a dependency when installing the php package and is where the php.ini file comes from in CentOS.

[[email protected] ~]# rpm -qc php-common
/etc/php.d/curl.ini
/etc/php.d/fileinfo.ini
/etc/php.d/json.ini
/etc/php.d/phar.ini
/etc/php.d/zip.ini
/etc/php.ini

These are all of the default configuration files that are installed by the php-common package, we can see here that by default the php.ini file is found at /etc/php.ini.

There are also a couple more configuration files from the php package.

[[email protected] ~]# rpm -qc php
/etc/httpd/conf.d/php.conf
/etc/httpd/conf.modules.d/10-php.conf

The php package requires the httpd package to be installed, which makes sense as these are the configuration files that tell Apache how to work with PHP.

Find Command

If you aren’t using packages to install PHP and perhaps compiled it from source instead or otherwise installed to a custom location, we can easily run find over the entire file system to find these files.

[[email protected] ~]# find / -name php.ini
/etc/php.ini

The above example will search through root file system ‘/’ and find every file named ‘php.ini’.

PHPInfo

We can create a simple phpinfo file and open it in a browser to display the location of the php.ini file that is being used. Copy the below into a .php file and navigate to it within a browser to view this information. You should delete the file once you’re done, as this can provide a lot of information to an attacker.

<?php
phpinfo();
?>

The “Configuration File (php.ini) Path” shows the directory the php.ini file can be found in, while “Loaded Configuration File” shows the full path to the file.

php.ini file location

Summary

With these simple methods we can quickly search the file system to find all php.ini files, or simply display the php.ini file that our php file is currently making use of thanks to phpinfo.

Change the PHP Version on a Plesk Server

Change the PHP Version on a Plesk Server

Learn how to change the PHP version for a server with Plesk. This tutorial includes instructions on how to find the PHP version your Plesk server is using, change to a different PHP version, and install a different PHP version if necessary.

Change the PHP Version on a Plesk Server

Install and Use PHP Composer on Ubuntu 16.04

Install and Use PHP Composer on Ubuntu 16.04

PHP Composer is a package management system for PHP which prevents users from having to «reinvent the wheel» when it comes to commonly-used website components like user authentication or database management. Composer is modelled on other popular package management systems like Ruby’s Bundler.

Install and Use PHP Composer on Ubuntu 16.04

Using PHP Composer in IONOS Webhosting Packages

Using PHP Composer in IONOS Webhosting Packages

Composer is a so-called «Dependency Management Tool», which makes it possible to comfortably reference external sources and libraries in one’s own PHP projects and to keep them up-to-date.

Using PHP Composer in IONOS Webhosting Packages

PHP 8: What you need to know about the latest version

PHP 8: What you need to know about the latest version

PHP is one of the most important languages on the Internet. Many content management systems like WordPress, TYPO3 or Joomla are based on PHP. With the release of PHP 8, various new features were introduced. Also some old features were reworked, meaning that errors may occur if the code is not up to date. You can find all the important information about the new features of PHP 8 here.

PHP 8: What you need to know about the latest version

There are several ways to find the php.ini file location in Ubuntu and Centos Linux servers. It is also interesting to note that there are usually several php.ini files on the server. Here will show you how to find the file and determine which one is the active configuration file.

Using Locate to Find php.ini File Location

Use the following command to get a list of all of the php.ini files.

$ locate php.ini

This will give an output similar to this:

/etc/php/7.2/apache2/php.ini
/etc/php/7.2/cli/php.ini
/etc/php/7.2/fpm/php.ini
/etc/php/7.3/cli/php.ini
/etc/php/7.4/apache2/php.ini
/etc/php/7.4/apache2/php.ini.save
/etc/php/7.4/apache2/php.ini.ucf-dist
/etc/php/7.4/cli/php.ini
/etc/php/7.4/cli/php.ini.ucf-dist
/etc/php/7.4/fpm/php.ini
/etc/php/7.4/fpm/php.ini.ucf-dist
/etc/php/8.0/cli/php.ini
/usr/lib/php/5.6/php.ini-development
/usr/lib/php/5.6/php.ini-production
/usr/lib/php/5.6/php.ini-production.cli
/usr/lib/php/7.0/php.ini-development
/usr/lib/php/7.0/php.ini-production
/usr/lib/php/7.0/php.ini-production.cli
/usr/lib/php/7.1/php.ini-development
/usr/lib/php/7.1/php.ini-production
/usr/lib/php/7.1/php.ini-production.cli
/usr/lib/php/7.2/php.ini-development
/usr/lib/php/7.2/php.ini-production
/usr/lib/php/7.2/php.ini-production.cli
/usr/lib/php/7.3/php.ini-development
/usr/lib/php/7.3/php.ini-production
/usr/lib/php/7.3/php.ini-production.cli
/usr/lib/php/7.4/php.ini-development
/usr/lib/php/7.4/php.ini-production
/usr/lib/php/7.4/php.ini-production.cli
/usr/lib/php/8.0/php.ini-development
/usr/lib/php/8.0/php.ini-production
/usr/lib/php/8.0/php.ini-production.cli

The above output may not be very helpful in drilling down to the active php.ini file location.

You can use the PHP CLI to get the configuration file that is being used in your setup with the following command:

$ php -i | grep 'php.ini'

From the output look for the line similar to this:

Loaded Configuration File => /etc/php/7.4/cli/php.ini

You can also use the following to retrieve the same output:

$ php -r "echo php_ini_loaded_file().PHP_EOL;"

With the expected result being:

/etc/php/7.4/cli/php.ini

You can use PHPs phpinfo function as follows:

$ php -r "phpinfo();" | grep php.ini

With the following as the result.

Configuration File (php.ini) Path => /etc/php/7.4/cli
Loaded Configuration File => /etc/php/7.4/cli/php.ini

In case you need to get the php.ini file location for the settings used by the webserver you will need to use the following function from within a PHP file created in the web server document root and accessed from a web browser.

echo php_ini_loaded_file().PHP_EOL;

There you have it you should now be able to find the php.ini file location in Ubuntu and Centos Linux servers including determining the one that is active.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Понравилась статья? Поделить с друзьями:
  • Как найти свою декларацию в реестре
  • Гиперактивный ребенок как найти общи
  • Как найти драйвер для android
  • Файл открыт как найти его путь
  • Как найти протяженность материка в градусах австралия