El Capitan 上的 PHP.ini 位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34133125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:46:48  来源:igfitidea点击:

PHP.ini location on El Capitan

phpapacheosx-elcapitanphp-ini

提问by delphirules

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 /etcfolder, but nothing changed.

我试图更新/etc文件夹中的那个,但没有任何改变。

采纳答案by davejal

Simple solution

简单的解决方案

  1. create php info file in your web folder

    <?php
    
     // Show all information, defaults to INFO_ALL
    phpinfo();
    
    ?>
    
  2. open the file in browser

  3. look for

  1. 在您的 web 文件夹中创建 php 信息文件

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

  3. 寻找

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(); ?>

回答by Simon Backx

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. Don't forget to create a copy if you want to make changes:

但如果该文件不存在,php 将使用/etc/php.ini.default. 如果要进行更改,请不要忘记创建副本:

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

Also, php will scan /Library/Server/Web/Config/phpdir for additional .ini files

此外,php 将扫描/Library/Server/Web/Config/phpdir 以获取其他 .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

回答by Jirson Tavera

i know three ways:

我知道三种方式:

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

回答by gonza

Strange thing that phpinfo() does not display the file location, but here it is: /etc/php.ini.default

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

回答by Zia

This is a polished version of "Simple solution", someone posted before

这是“简单解决方案”的精制版,之前有人发过

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