Untuk mencari tahu di mana file php.ini_ Anda berada, buat file PHP bernama ini.php di root web Anda (bersama file index.php Anda) dengan ini
<?php echo 'Loaded php.ini: ' . php_ini_loaded_file();Kemudian akses file itu di browser web Anda dengan membuka //your-project.nitro/ini.php
Ada kemungkinan besar bahwa file php.ini akan berbeda untuk permintaan konsol. Jika Anda perlu melakukan perubahan yang menargetkan permintaan konsol, buka terminal Anda dan jalankan perintah ini
php -i | grep 'Loaded Configuration File' _Atau jika Anda berada di server Windows
php -i | find "Loaded Configuration File"Setelah Anda mengetahui di mana file php.ini_ Anda berada, Anda dapat membukanya dengan editor teks favorit Anda untuk mengubahnya
Misalnya, kami menyarankan Anda mengatur pengaturan setidaknya php -i | grep 'Loaded Configuration File' 2 (dua menit), untuk mengakomodasi operasi Komposer yang berjalan lama
max_execution_time = 120 _Kerajinan juga membutuhkan nilai php -i | grep 'Loaded Configuration File' _3 minimal php -i | grep 'Loaded Configuration File' 4
Sebelum menambahkan baris baru apa pun ke file, cari pengaturan yang ingin Anda ubah, dan pastikan itu belum ditentukan di suatu tempat
Mungkin pengaturannya terdaftar, tetapi dikomentari. Untuk membatalkan komentar, hapus php -i | grep 'Loaded Configuration File' _5 dari awal baris
File konfigurasi (php. ini) dibaca saat PHP dijalankan. Untuk versi modul server PHP, ini terjadi hanya sekali saat server web dimulai. Untuk versi CGI dan CLI, ini terjadi pada setiap pemanggilan
php. ini dicari di lokasi ini (berurutan)
- Lokasi spesifik modul SAPI (PHPIniDir_ direktif di Apache 2, -c opsi baris perintah di CGI dan CLI)
- Variabel lingkungan PHPRC
- Lokasi file php.ini_ dapat diatur untuk versi PHP yang berbeda. Akar kunci registri tergantung pada 32- atau 64-bit dari OS dan PHP yang diinstal. Untuk PHP 32-bit pada OS 32-bit atau PHP 64-bit pada OS 64-bit, gunakan [(HKEY_LOCAL_MACHINE\SOFTWARE\PHP] untuk PHP versi 32-bit pada OS 64-bit gunakan [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PHP]] sebagai gantinya. Untuk instalasi bitness yang sama, kunci registri berikut diperiksa secara berurutan. [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z], [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] dan ; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"0, di mana x, y dan z berarti versi mayor, minor, dan rilis PHP. Untuk versi 32 bit PHP pada OS 64 bit, kunci registri berikut diperiksa secara berurutan. ; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"1, ; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"2 dan ; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"3, di mana x, y dan z berarti versi mayor, minor, dan rilis PHP. Jika ada nilai untuk ; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"_4 di salah satu kunci ini, yang pertama ditemukan akan digunakan sebagai lokasi php.ini (khusus Windows)
- ; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"6 atau [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PHP], senilai ; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"4 (khusus Windows)
- Direktori kerja saat ini (kecuali CLI)
- Direktori server web (untuk modul SAPI), atau direktori PHP (jika tidak di Windows)
- Direktori Windows (C. \windows atau C. \winnt) (untuk Windows), atau ; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"9 opsi waktu kompilasi
Jika php-SAPI. ini ada (di mana SAPI adalah SAPI yang digunakan, jadi, misalnya, php-cli. ini atau php-apache. ini), ini digunakan sebagai pengganti php. ini. Nama SAPI dapat ditentukan dengan php_sapi_name()
Catatan
Server web Apache mengubah direktori menjadi root saat startup, menyebabkan PHP mencoba membaca php. ini dari sistem file root jika ada
Menggunakan variabel lingkungan dapat digunakan di php. ini seperti yang ditunjukkan di bawah ini
Contoh #1 php. ini Variabel Lingkungan
; PHP_MEMORY_LIMIT is taken from environment memory_limit = ${PHP_MEMORY_LIMIT}
php. Ini arahan ditangani oleh ekstensi didokumentasikan pada halaman masing-masing ekstensi itu sendiri. Daftar arahan inti tersedia di lampiran. Tidak semua arahan PHP harus didokumentasikan dalam manual ini. untuk daftar lengkap arahan yang tersedia dalam versi PHP Anda, silakan baca php Anda yang dikomentari dengan baik. file ini. Atau, Anda dapat menemukan » php.ini terbaru. ini dari Git juga membantu
Contoh #2 php. ini contoh
; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"_
Dimungkinkan untuk merujuk pada yang sudah ada. variabel ini dari dalam. file ini. Contoh. Assuming PHP is configured with --with-config-file-scan-dir=/etc/php.d, and that the path separator is :... $ php PHP will load all files in /etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d php PHP will load all files in /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=:/usr/local/etc/php.d php PHP will load all files in /etc/php.d/*.ini, then /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d: php PHP will load all files in /usr/local/etc/php.d/*.ini, then /etc/php.d/*.ini as configuration files. _0
Pindai direktori
Dimungkinkan untuk mengonfigurasi PHP untuk memindai. Ini file dalam direktori setelah membaca php. ini. Ini dapat dilakukan pada waktu kompilasi dengan menyetel opsi --with-config-file-scan-dir. Direktori pemindaian kemudian dapat ditimpa saat dijalankan dengan menyetel variabel lingkungan PHP_INI_SCAN_DIR
Dimungkinkan untuk memindai banyak direktori dengan memisahkannya dengan pemisah jalur khusus platform (Assuming PHP is configured with --with-config-file-scan-dir=/etc/php.d, and that the path separator is :... $ php PHP will load all files in /etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d php PHP will load all files in /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=:/usr/local/etc/php.d php PHP will load all files in /etc/php.d/*.ini, then /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d: php PHP will load all files in /usr/local/etc/php.d/*.ini, then /etc/php.d/*.ini as configuration files. 1 di Windows, NetWare, dan RISC OS; Assuming PHP is configured with --with-config-file-scan-dir=/etc/php.d, and that the path separator is :... $ php PHP will load all files in /etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d php PHP will load all files in /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=:/usr/local/etc/php.d php PHP will load all files in /etc/php.d/*.ini, then /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d: php PHP will load all files in /usr/local/etc/php.d/*.ini, then /etc/php.d/*.ini as configuration files. 2 di semua platform lain; nilai yang digunakan PHP tersedia sebagai konstanta Assuming PHP is configured with --with-config-file-scan-dir=/etc/php.d, and that the path separator is :... $ php PHP will load all files in /etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d php PHP will load all files in /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=:/usr/local/etc/php.d php PHP will load all files in /etc/php.d/*.ini, then /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d: php PHP will load all files in /usr/local/etc/php.d/*.ini, then /etc/php.d/*.ini as configuration files. 3). Jika direktori kosong diberikan dalam PHP_INI_SCAN_DIR, PHP juga akan memindai direktori yang diberikan pada waktu kompilasi melalui --with-config-file-scan-dir
Dalam setiap direktori, PHP akan memindai semua file yang diakhiri dengan Assuming PHP is configured with --with-config-file-scan-dir=/etc/php.d, and that the path separator is :... $ php PHP will load all files in /etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d php PHP will load all files in /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=:/usr/local/etc/php.d php PHP will load all files in /etc/php.d/*.ini, then /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d: php PHP will load all files in /usr/local/etc/php.d/*.ini, then /etc/php.d/*.ini as configuration files. 4 dalam urutan abjad. Daftar file yang dimuat, dan urutannya, tersedia dengan memanggil php_ini_scanned_files(), atau dengan menjalankan PHP dengan opsi --ini