Hướng dẫn what is php config file? - tập tin cấu hình php là gì?

Tệp cấu hình (php.ini) được đọc khi PHP khởi động. Đối với các phiên bản mô -đun máy chủ của PHP, điều này chỉ xảy ra một lần khi máy chủ web được khởi động. Đối với các phiên bản CGI và CLI, nó xảy ra trên mỗi lần gọi.

Php.ini được tìm kiếm ở các địa điểm này (theo thứ tự):

  • Vị trí cụ thể của mô -đun SAPI (Chỉ thị PHPIniDir trong Apache 2, -c Tùy chọn dòng lệnh trong CGI và CLI)
  • Biến môi trường PHPRC.
  • Vị trí của tệp php.ini có thể được đặt cho các phiên bản khác nhau của PHP. Rễ của các khóa đăng ký phụ thuộc vào độ 32 hoặc 64 bit của HĐH và PHP đã cài đặt. Đối với PHP 32 bit trên HĐH 32 bit hoặc PHP 64 bit trên hệ điều hành 64 bit sử dụng [(HKEY_LOCAL_MACHINE\SOFTWARE\PHP] cho phiên bản PHP 32 bit trên hệ điều hành 64 bit sử dụng [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PHP]]. Đối với cùng một cài đặt bitness, các khóa đăng ký sau đây được kiểm tra theo thứ tự: [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z], [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y]
    ; 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, trong đó X, Y và Z có nghĩa là các phiên bản chính, nhỏ và phát hành PHP. Đối với các phiên bản 32 bit của PHP trên hệ điều hành 64 bit, các khóa đăng ký sau được kiểm tra theo thứ tự:
    ; 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 và
    ; 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, trong đó X, Y và Z có nghĩa là các phiên bản chính, nhỏ và phát hành PHP. Nếu có giá trị cho
    ; 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 trong bất kỳ khóa nào trong số này, thì cái đầu tiên được tìm thấy sẽ được sử dụng làm vị trí của php.ini (chỉ 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 hoặc [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PHP], giá trị của
    ; 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 (chỉ Windows).
  • Thư mục làm việc hiện tại (trừ CLI).
  • Thư mục của máy chủ web (cho các mô -đun SAPI) hoặc thư mục của PHP (nếu không trong Windows).
  • Thư mục Windows (C: \ Windows hoặc C: \ WINNT) (cho Windows) hoặc tùy chọn thời gian biên dịch
    ; 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.

Nếu php-sapi.ini tồn tại (trong đó sapi là SAPI được sử dụng, vì vậy, ví dụ, php-cli.ini hoặc php-apache.ini), nó được sử dụng thay vì php.ini. Tên SAPI có thể được xác định bằng PHP_SAPI_NAME ().php_sapi_name().

Ghi chú::

Máy chủ web Apache thay đổi thư mục thành root khi khởi động, khiến PHP cố gắng đọc php.ini từ hệ thống tập tin gốc nếu nó tồn tại.

Sử dụng các biến môi trường có thể được sử dụng trong php.ini như hình dưới đây.

Ví dụ #1 Biến môi trường Php.ini

; PHP_MEMORY_LIMIT is taken from environment
memory_limit = ${PHP_MEMORY_LIMIT}

Các chỉ thị php.ini được xử lý bởi các tiện ích mở rộng được ghi lại trên các trang tương ứng của các phần mở rộng. Một danh sách các chỉ thị cốt lõi có sẵn trong Phụ lục. Không phải tất cả các chỉ thị PHP nhất thiết đều được ghi lại trong hướng dẫn này: Để biết danh sách đầy đủ các chỉ thị có sẵn trong phiên bản PHP của bạn, vui lòng đọc tệp PHP.ini được nhận xét tốt của bạn. Ngoài ra, bạn có thể tìm thấy »& nbsp; Php.ini mới nhất từ ​​git cũng hữu ích.

Ví dụ #2 Php.ini ví dụ

; 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"

Có thể tham khảo các biến .ini hiện có từ các tệp .ini. Ví dụ:

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.

Thư mục quét

Có thể định cấu hình PHP để quét các tệp .ini trong thư mục sau khi đọc php.ini. Điều này có thể được thực hiện tại thời điểm biên dịch bằng cách đặt tùy chọn--with-config-scan-scan-DIR. Thư mục quét sau đó có thể được ghi đè tại thời gian chạy bằng cách đặt biến môi trường PHP_INI_SCAN_DIR.--with-config-file-scan-dir option. The scan directory can then be overridden at run time by setting the PHP_INI_SCAN_DIR environment variable.

Có thể quét nhiều thư mục bằng cách tách chúng bằng bộ phân cách đường dẫn dành riêng cho nền tảng (

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 trên Windows, NetWare và 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 trên tất cả các nền tảng khác; Php giá trị đang sử dụng có sẵn dưới dạng hằng số
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). Nếu một thư mục trống được đưa ra trong PHP_INI_SCAN_DIR, PHP cũng sẽ quét thư mục được đưa ra tại thời điểm biên dịch thông qua--with-config-file-scan-dir.
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
constant). If a blank directory is given in PHP_INI_SCAN_DIR, PHP will also scan the directory given at compile time via --with-config-file-scan-dir.

Trong mỗi thư mục, PHP sẽ quét tất cả các tệp kết thúc theo thứ tự bảng chữ cái. Một danh sách các tệp đã được tải và theo thứ tự nào, có sẵn bằng cách gọi PHP_INI_SCPENT_FILES () hoặc bằng cách chạy PHP với tùy chọn -ini.php_ini_scanned_files(), or by running PHP with the --ini option.

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.

Weili ¶

1 năm trước

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.
5

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.
6

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.
7

OHCC tại 163 dot com ¶

6 năm trước

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.
8

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.
9

PHPIniDir0

PHPIniDir1

PHPIniDir2

PHPIniDir3

PHPIniDir4

PHPIniDir5

PHPIniDir6

PHPIniDir7

PHPIniDir8

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.
7

Tệp cấu hình PHP ở đâu?

Tệp INI là tệp cấu hình mặc định để chạy các ứng dụng yêu cầu PHP. Nó được sử dụng để kiểm soát các biến như kích thước tải lên, thời gian chờ tệp và giới hạn tài nguyên. Tệp này được đặt trên máy chủ của bạn trong thư mục /public_html.on your server in the /public_html folder.

Các tệp cấu hình làm gì?

Tệp cấu hình, thường được rút ngắn thành tệp cấu hình, xác định các tham số, tùy chọn, cài đặt và tùy chọn được áp dụng cho các hệ điều hành (HĐH), thiết bị cơ sở hạ tầng và ứng dụng trong bối cảnh CNTT.defines the parameters, options, settings and preferences applied to operating systems (OSes), infrastructure devices and applications in an IT context.

Cấu hình PHP hoạt động như thế nào?

WP-config.Tệp PHP là một tệp cấu hình được tạo trong quá trình cài đặt WordPress.Nó lưu trữ thông tin cơ sở dữ liệu như tên cơ sở dữ liệu, tên người dùng, mật khẩu và máy chủ.Ngoài việc thiết lập kết nối giữa trang web WordPress của bạn và cơ sở dữ liệu của nó, WordPress còn sử dụng WP-Config.It stores database information such as the database name, username, password, and host. In addition to establishing a connection between your WordPress site and its database, WordPress also uses the wp-config.

Điều gì nên có trong tệp PHP INI của tôi?

PHP.Tệp INI chứa tất cả các cài đặt cấu hình PHP hiện tại: chẳng hạn như thời gian thực hiện, giới hạn bộ nhớ, v.v ... Đây cũng là cách bật các mô -đun PECL như MemCache, APC, v.v. Tệp này cho phép bạn ghi đè cài đặt cấu hình mặc định của máy chủ.all of the current PHP configuration settings: such as the execution time, memory limit, etc. This is also how PECL modules are enabled such as memcache, APC, etc. This file allows you to override the server's default configuration settings.