Modifying PHP Settings
ServBay includes a PHP environment with flexible configuration options. This article will detail how to modify PHP settings in ServBay, including the locations of php.ini
and php-fpm.conf
files, as well as common configuration items. Depending on the PHP version, these files are located in the /Applications/ServBay/etc/php/<version>
directory. Additionally, PHP module configuration files (such as xdebug.ini
) are located in the /Applications/ServBay/etc/php/<version>/conf.d
directory.
Important Note
Please do not manually modify configuration files. All configuration files are automatically generated by ServBay, and manual modifications risk being overwritten. Please make changes through the UI.
Overview
In ServBay, PHP configuration files are stored in different directories based on the version. For example, PHP 8.3 configuration files 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/
Modifying via ServBay’s UI
ServBay provides a powerful graphical management interface where users can modify various configuration parameters. After clicking save, changes are automatically applied and take effect in real time, eliminating the need for manual parameter editing.
Open Language
from the left navigation, select the PHP version you wish to modify, and an editing menu will appear on the right. A typical interface is shown in the image below.
The interface is divided into three different configuration items, corresponding to PHP-FPM, PHP, and PHP modules. Below, these will be explained one by one.
PHP FPM
Tip
php-fpm.conf
corresponds to the performance of PHP in web services, and all configurations will take precedence over (override) php.ini
.
However, settings here will not affect the performance of code in the CLI.
First is the PHP FPM configuration interface. Whether it's Caddy or NGINX, PHP in ServBay web services runs using FPM. In this interface, you can configure the number of FPM processes, memory limits, log error levels, whether to display error information in the browser, etc.
For example, if we want to change the Memory Limit
in the web from 64M to 1G, we simply select 1G
in the Memory Limit
dropdown menu and save. This modification will not affect the php.ini
configuration, and PHP scripts running in CLI mode will still be controlled by php.ini
.
Assuming php.ini
has a Memory Limit
of 512M
, but PHP FPM
is configured with a Memory Limit
of 128M
, then the same script can use 512M of memory in CLI and 128M in web.
php.ini
Tip
Settings in php.ini
are global, affecting both CLI and web contexts. However, in the web context, php.ini
settings might be overridden by php-fpm.conf
.
The PHP configuration section corresponds to the configuration items in php.ini
, which is PHP's core configuration file.
Here, you can configure most php.ini
options, such as post_max_size
affecting post forms and upload_max_filesize
affecting uploaded file sizes, as well as disable_functions
and disable_classes
.
Note that because settings are global, if you want to configure open_basedir
, it's recommended to place all website projects in /Applications/ServBay/www
to avoid setting multiple directories.
For detailed configuration fields, refer to the official php.ini documentation.
Extension Modules
ServBay comes with a variety of common PHP extension modules, such as xDebug
, OPcache
, Image Magick
, Redis
, MongoDB
, Phalcon
, Swoole
, etc. For a detailed list of modules, refer to PHP Extension Module List.
Enabling PHP extension modules is very simple, just toggle the switch and click save. For modules like xDebug that have additional configuration items, these can be easily modified directly.
Modifying via Manual Configuration File Editing
WARNING
Editing configuration files manually is only suitable for temporary changes to certain configuration items.
We do not recommend manually modifying PHP configuration files because all changes will be overwritten by ServBay.
php.ini Configuration
The php.ini
file is PHP's main configuration file, used to set various runtime options for PHP.
Common Configuration Items
Below 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 PHP-FPM (FastCGI Process Manager) runtime parameters.
Common Configuration Items
Below 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 /Applications/ServBay/etc/php/8.3/conf.d/
. For example, the xdebug.ini
file is used to configure the Xdebug extension.
xdebug.ini Example
Below 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
Restarting PHP
After modifying PHP configuration files, you need to restart the PHP service to apply the changes. This can be done through ServBay's management interface or using the servbayctl
command-line tool.
Restart via ServBay Management Interface
- Open ServBay management interface.
- Navigate to
Services
. - Find the PHP service for the appropriate version and click the
Restart
button.
Restart via servbayctl
Using the servbayctl
command-line tool, you can easily restart the PHP service:
servbayctl restart php 8.3
Summary
In ServBay, PHP configuration files are located in /Applications/ServBay/etc/php/<version>
, including php.ini
and php-fpm.conf
. PHP module loading configuration files are located in /Applications/ServBay/etc/php/<version>/conf.d/
. After modifying these configuration files, you can restart the PHP service via ServBay's management interface or using the servbayctl
command-line tool to apply the changes.