Where are the ini files on the MacOsX Sierra?

I just bought a new MacBook Pro. See what php -i | grep ini returns php -i | grep ini php -i | grep ini :

 prompt> php -i | grep ini Configuration File (php.ini) Path => /etc Scan this dir for additional .ini files => (none) Additional .ini files parsed => (none) user_ini.cache_ttl => 300 => 300 user_ini.filename => .user.ini => .user.ini Supported handlers => ndbm cdb cdb_make inifile flatfile init_command_executed_count => 0 init_command_failed_count => 0 com_init_db => 0 Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException open sourced by => Epinions.com , BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException prompt> php -i | grep ini Configuration File (php.ini) Path => /etc Scan this dir for additional .ini files => (none) Additional .ini files parsed => (none) user_ini.cache_ttl => 300 => 300 user_ini.filename => .user.ini => .user.ini Supported handlers => ndbm cdb cdb_make inifile flatfile init_command_executed_count => 0 init_command_failed_count => 0 com_init_db => 0 Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException open sourced by => Epinions.com , RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException prompt> php -i | grep ini Configuration File (php.ini) Path => /etc Scan this dir for additional .ini files => (none) Additional .ini files parsed => (none) user_ini.cache_ttl => 300 => 300 user_ini.filename => .user.ini => .user.ini Supported handlers => ndbm cdb cdb_make inifile flatfile init_command_executed_count => 0 init_command_failed_count => 0 com_init_db => 0 Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException open sourced by => Epinions.com 

And this is what happens when I run php --ini

 prompt> $ php --ini Configuration File (php.ini) Path: /etc Loaded Configuration File: (none) Scan for additional .ini files in: (none) Additional .ini files parsed: (none) 

It seems that the current php is not loading the php.ini file. Is it possible?

+21
source share
8 answers

Current versions of Mac OS X do not ship with php.ini . PHP uses internal defaults for all parameters.

There is an example configuration file installed in /etc/php.ini.default . If you need to configure PHP settings, you can use this file as a template to create a configuration file in /etc/php.ini . PHP will read the settings from this file, if present.

+49
source

Change: the following method has been tested, and I confirm that it works on MacOS, Linux and Windows CMD and Bash

All you need to type in terminal / CMD / Bash is

 php --ini 

It will be something like:

 Configuration File (php.ini) Path: /usr/local/etc/php/5.6 Loaded Configuration File: /usr/local/etc/php/5.6/php.ini Scan for additional .ini files in: /usr/local/etc/php/5.6/conf.d Additional .ini files parsed: (none) 
+23
source

There is a php function php_ini_loaded_file () that returns the path to the loaded php.ini.

Try using the code below.

 <?php $inipath = php_ini_loaded_file(); if ($inipath) { echo 'Loaded php.ini: ' . $inipath; } else { echo 'A php.ini file is not loaded'; } ?> 
+5
source

You can use the find to search for the file system for php.ini or something else. This can take a long time, depending on the size of your file system. If you want to stop the search, you can do CTRL-C .

 find / -type f -name php.ini 

If you are not a root user, you will receive a permission denial message, if you want to run it as root, you can do this.

 sudo find / -type f -name php.ini 

Here is a search tutorial if you are interested in some other examples.

http://www.tecmint.com/35-practical-examples-of-linux-find-command/

+2
source
 php -r "echo php_ini_loaded_file();" 

on my machine returns:

 /usr/local/etc/php/7.1/php.ini 

;)

+2
source

This worked for me on MacOS Sierra with PHP 7.1 installed:

  • Create a php file called phpinfo_temp.php (remember to delete this file when you are done):

    <?php phpinfo(); ?>

  • Download the file and you will see about 7 variables: "Loaded configuration file:". This is a downloaded php file.

  • Save the php.ini file before editing:

    sudo cp /usr/local/php5/lib/php.ini /usr/local/php5/lib/php.ini.backup

  • Then edit php.ini

    sudo nano /usr/local/php5/lib/php.ini

  • Once you are done editing restart your apache server

    sudo apachectl restart

+1
source

most often the .ini file does not exist as is, but it is called .ini.default in /etc

0
source

I will add an updated answer for anyone dealing with this on MacOS Mojave and PHP 7.1

Running php --ini in the terminal returned this:

 Configuration File (php.ini) Path: /etc Loaded Configuration File: (none) Scan for additional .ini files in: (none) Additional .ini files parsed: (none) 

I found the php.ini.default file in /private/etc/ , duplicated it and renamed it to php.ini , which now loads correctly:

 Configuration File (php.ini) Path: /etc Loaded Configuration File: /etc/php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none) 
0
source

Source: https://habr.com/ru/post/1012187/


All Articles