简体   繁体   English

El Capitan上的PHP.ini位置

[英]PHP.ini location on El Capitan

Simple question: where is the correct PHP.INI location in Mac OSX El Capitan? 简单的问题:Mac OSX El Capitan中正确的PHP.INI位置在哪里?

I tried to update the one in /etc folder, but nothing changed. 我试图更新/ etc文件夹中的那个,但没有任何改变。

The default location on OSX El Capitan and macOS Sierra is /etc/php.ini OSX El Capitan和macOS Sierra上的默认位置是/etc/php.ini

But if that file doesn't exist, php will use /etc/php.ini.default . 但如果该文件不存在,php将使用/etc/php.ini.default Don't forget to create a copy if you want to make changes: 如果要进行更改,请不要忘记创建副本:

$ sudo cp /etc/php.ini.default /etc/php.ini   

Also, php will scan /Library/Server/Web/Config/php dir for additional .ini files 此外,php将扫描/Library/Server/Web/Config/php目录以获取其他.ini文件

Restart Apache if you made any changes: 如果进行了任何更改,请重启Apache:

$ sudo apachectl -k restart  

Note: if you install PHP7, this location will change to /usr/local/etc/php/7.0/php.ini 注意:如果您安装PHP7,此位置将更改为/usr/local/etc/php/7.0/php.ini

i know three ways: 我知道三种方式:

  1. php -i | php -i | grep php.ini grep php.ini
  2. php --ini php --ini
  3. create php file with following line: <?php phpinfo(); 使用以下行创建php文件: <?php phpinfo(); and open the file in the browser 并在浏览器中打开该文件

Simple solution 简单解决方案

  1. create php info file in your web folder 在您的web文件夹中创建php信息文件

     <?php // Show all information, defaults to INFO_ALL phpinfo(); ?> 
  2. open the file in browser 在浏览器中打开文件

  3. look for 寻找

INFO_GENERAL 1 The configuration line, php.ini location, build date, Web Server, System and more. INFO_GENERAL 1配置行,php.ini位置,构建日期,Web服务器,系统等。

Taken from php manual 取自php手册


Another option is to use 另一种选择是使用

<? php_ini_loaded_file(); ?>

奇怪的是,phpinfo()不显示文件位置,但这里是: /etc/php.ini.default

This is a polished version of "Simple solution", someone posted before 这是之前发布的“简单解决方案”的精美版本

  1. create php info file in your web folder 在您的web文件夹中创建php信息文件
  2. <?php phpinfo();?>
  3. open the file in browser 在浏览器中打开文件
  4. look for php.ini 寻找php.ini

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM