假设我已经在Ubuntu中安装了PHP 5.5.x,并且它带有默认配置。我想要覆盖一些配置,但我不想(这就是我知道它是可能的):
- 编辑默认的php.ini文件 - 在每个.php文件中使用PHP块来覆盖它们 - 使用.htaccess文件和指令
我想创建一个名为custom-php.ini的文件,并包含以下内容(作为示例):
- 编辑默认的php.ini文件 - 在每个.php文件中使用PHP块来覆盖它们 - 使用.htaccess文件和指令
我想创建一个名为custom-php.ini的文件,并包含以下内容(作为示例):
; Basic configuration override
expose_php = Off
memory_limit = 512M
post_max_size = 128M
upload_max_filesize = 128M
date.timezone = UTC
max_execution_time = 120
; Error reporting
display_errors = stderr
display_startup_errors = Off
error_reporting = E_ALL
; A bit of performance tuning
realpath_cache_size = 128k
; OpCache tuning
opcache.max_accelerated_files = 32000
; Temporarily disable using HUGE PAGES by OpCache.
; This should improve performance, but requires appropriate OS configuration
; and for now it often results with some weird PHP warning:
; PHP Warning: Zend OPcache huge_code_pages: madvise(HUGEPAGE) failed: Invalid argument (22) in Unknown on line 0
opcache.huge_code_pages=0
; Xdebug
[Xdebug]
xdebug.remote_enable = true
xdebug.remote_host = "192.168.3.1" // this IP should be the host IP
xdebug.remote_port = "9001"
xdebug.idekey = "XDEBUG_PHPSTORM"
我能否在某个地方编写此文件,以便默认的PHP值被custom-php.ini
中的值所覆盖?
/etc/php/conf.d
的东西吗?您应该能够在其中放置部分配置,这将覆盖主配置文件。 - Chrisini_set()
。 - ReynierPMini_set()
是一种代码异味。它几乎永远不应该被使用。PHP允许在太多地方进行配置... - Chris