讓我們說,我已經在Ubuntu中安裝了PHP 5.5.x,它帶有一個默認配置。我想覆蓋一些配置,但我不希望(這就是我知道這是可能的):如何覆蓋一些PHP的默認配置?
- 編輯默認
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
上的那些文件覆蓋嗎?
我沒有附近的Ubuntu機器來檢查,但沒有像'/ etc/php/conf.d'這樣的東西嗎?你應該能夠在那裏放置一個部分配置,它將覆蓋主配置文件。 – Chris
不需要** ini_set()**,ya? –
@TheOneandOnlyChemistryBlob是的,我不想爲每個文件添加這樣的行;) – ReynierPM