修改PHP設定
ServBay自帶了PHP環境,並且提供了靈活的配置選項。本文將詳細介紹如何修改ServBay中的PHP設定,包括php.ini
和php-fpm.conf
文件的位置和常見的配置項。根據PHP版本的不同,這些文件位於/Applications/ServBay/etc/php/<version>
目錄中。另外,PHP模組的加載配置文件(如xdebug.ini
)位於/Applications/ServBay/etc/php/<version>/conf.d
目錄中。
概述
在ServBay中,PHP的配置文件根據版本存放在不同的目錄中。例如,PHP 8.3的配置文件位於/Applications/ServBay/etc/php/8.3
目錄中。以下是這些配置文件的詳細位置:
php.ini
:/Applications/ServBay/etc/php/8.3/php.ini
php-fpm.conf
:/Applications/ServBay/etc/php/8.3/php-fpm.conf
- PHP模組加載配置文件:
/Applications/ServBay/etc/php/8.3/conf.d/
php.ini配置
php.ini
文件是PHP的主配置文件,用於設置PHP的各種執行時選項。
常見配置項
以下是一些常見的php.ini
配置項及其修改方式:
修改內存限制:
memory_limit = 256M
1修改上傳文件大小限制:
upload_max_filesize = 50M post_max_size = 50M
1
2修改時區設置:
date.timezone = "Asia/Hong_Kong"
1啟用錯誤顯示:
display_errors = On error_reporting = E_ALL
1
2修改最大執行時間:
max_execution_time = 300
1
php-fpm.conf配置
php-fpm.conf
文件用於配置PHP-FPM(FastCGI Process Manager)的執行參數。
常見配置項
以下是一些常見的php-fpm.conf
配置項及其修改方式:
修改進程池設置:
[www] listen = /Applications/ServBay/tmp/php-cgi-8.3.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 ;listen.owner = www ;listen.group = www listen.mode = 0666 ;user = www ;group = www pm = dynamic pm.max_children = 10 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 6 pm.max_requests = 1024 pm.process_idle_timeout = 10s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16啟用慢日誌:
request_slowlog_timeout = 5s slowlog = /Applications/ServBay/logs/php/8.3/slow.log
1
2修改錯誤日誌路徑:
error_log = /Applications/ServBay/logs/php/8.3/errors.log
1
PHP模組加載配置
PHP模組的加載配置文件位於/Applications/ServBay/etc/php/8.3/conf.d/
目錄中。例如,xdebug.ini
文件用於配置Xdebug擴展。
xdebug.ini示例
以下是一個xdebug.ini
文件的示例:
[Xdebug]
; Uncomment the following line to enable XDebug
zend_extension = xdebug.so
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.client_host=localhost
xdebug.client_port=39083
xdebug.log=/Applications/ServBay/logs/xdebug/8.3/xdebug.log
2
3
4
5
6
7
8
重啟PHP
修改完PHP配置文件後,需要重啟PHP服務以使更改生效。可以通過ServBay的管理介面或者使用servbayctl
命令行工具進行重啟。
通過ServBay管理介面重啟
- 打開ServBay管理介面。
- 導航到
服務
。 - 找到對應版本的PHP服務,並點擊
重啟
按鈕。
通過servbayctl重啟
使用命令行工具servbayctl
可以方便地重啟PHP服務:
servbayctl restart php 8.3
總結
在ServBay中,PHP的配置文件位於/Applications/ServBay/etc/php/<version>
目錄中,包括php.ini
和php-fpm.conf
。PHP模組的加載配置文件位於/Applications/ServBay/etc/php/<version>/conf.d/
目錄中。修改這些配置文件後,可以通過ServBay的管理介面或者使用servbayctl
命令行工具重啟PHP服務以使更改生效。