LoginSignup
22
24

More than 5 years have passed since last update.

PHPの設定ファイルの優先順位メモ

Last updated at Posted at 2017-06-05

設定ファイルの優先順位

ふとした拍子に忘れてしまうのでメモしておく。

優先順位

設定ファイルの優先順位は以下の通り。
右に行くほど後から読み込まれる(=左で設定した内容を上書きする)

php.ini < httpd.conf < .htaccess < ini_set()

この設定の内、、php.iniに書かれた内容は"Master Value"。
httpd.conf.htaccessini_set()関数で設定される値は"Local Value"となる。

これらの設定はCLI上でphp -iコマンド(Local Valueのみ)、もしくはphpinfo()をソースコードに記述して実行することで確認可能。

設定ファイルの場所を探すコマンド早見表

ファイル 探し方 備考
php.ini $ php -i | grep php.ini
を実行。
もしくはphpinfo()で確認可能
httpd.conf 3つの内いずれか
(ソースインストール等):/usr/local/apache2/conf/
(CentOS等):/etc/httpd/conf/
(MacOS等):/etc/apache2/
$ps aux | grep httpd
でプロセスを確認して3つ内どれか判断する。
コチラを参照
.htaccess --- 制御したいディレクトリにある
ini_set() --- ソースコードにある
22
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
24