Modify PHP Settings
ServBay comes with a built-in PHP environment and offers flexible configuration options. This article will detail how to modify PHP settings in ServBay, including the locations of the php.ini
and php-fpm.conf
files and common configuration items. Depending on the PHP version, these files are located in the /Applications/ServBay/etc/php/<version>
directory. Additionally, PHP module loading configuration files (such as xdebug.ini
) are located in the /Applications/ServBay/etc/php/<version>/conf.d
directory.
Overview
In ServBay, PHP configuration files are stored in different directories according to their versions. For example, the configuration files for PHP 8.3 are located in the /Applications/ServBay/etc/php/8.3
directory. Here are the detailed locations of these configuration files:
php.ini
:/Applications/ServBay/etc/php/8.3/php.ini
php-fpm.conf
:/Applications/ServBay/etc/php/8.3/php-fpm.conf
- PHP module loading configuration files:
/Applications/ServBay/etc/php/8.3/conf.d/
php.ini Configuration
The php.ini
file is the main configuration file for PHP, used to set various runtime options for PHP.
Common Configuration Items
Here are some common php.ini
configuration items and how to modify them:
Modify Memory Limit:
memory_limit = 256M
1Modify Upload File Size Limit:
upload_max_filesize = 50M post_max_size = 50M
1
2Modify Timezone Settings:
date.timezone = "Asia/Hong_Kong"
1Enable Error Display:
display_errors = On error_reporting = E_ALL
1
2Modify Maximum Execution Time:
max_execution_time = 300
1
php-fpm.conf Configuration
The php-fpm.conf
file is used to configure the runtime parameters of PHP-FPM (FastCGI Process Manager).
Common Configuration Items
Here are some common php-fpm.conf
configuration items and how to modify them:
Modify Process Pool Settings:
[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
16Enable Slow Log:
request_slowlog_timeout = 5s slowlog = /Applications/ServBay/logs/php/8.3/slow.log
1
2Modify Error Log Path:
error_log = /Applications/ServBay/logs/php/8.3/errors.log
1
PHP Module Loading Configuration
PHP module loading configuration files are located in the /Applications/ServBay/etc/php/8.3/conf.d/
directory. For example, the xdebug.ini
file is used to configure the Xdebug extension.
xdebug.ini Example
Here is an example of an xdebug.ini
file:
[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
Restart PHP
After modifying the PHP configuration files, you need to restart the PHP service to apply the changes. You can restart PHP through the ServBay management interface or by using the servbayctl
command-line tool.
Restart via ServBay Management Interface
- Open the ServBay management interface.
- Navigate to
Services
. - Find the corresponding PHP service version and click the
Restart
button.
Restart via servbayctl
You can easily restart the PHP service using the servbayctl
command-line tool:
servbayctl restart php 8.3
Summary
In ServBay, PHP configuration files are located in the /Applications/ServBay/etc/php/<version>
directory, including php.ini
and php-fpm.conf
. PHP module loading configuration files are located in the /Applications/ServBay/etc/php/<version>/conf.d/
directory. After modifying these configuration files, you can restart the PHP service through the ServBay management interface or by using the servbayctl
command-line tool to apply the changes.