Modificando Configurações do PHP
O ServBay vem com um ambiente PHP embutido e oferece opções de configuração flexíveis. Este artigo detalha como modificar as configurações do PHP no ServBay, incluindo a localização dos arquivos php.ini
e php-fpm.conf
e itens comuns de configuração. Dependendo da versão do PHP, esses arquivos estão localizados no diretório /Applications/ServBay/etc/php/<version>
. Além disso, os arquivos de configuração de carregamento de módulos do PHP (como xdebug.ini
) estão localizados no diretório /Applications/ServBay/etc/php/<version>/conf.d
.
Visão Geral
No ServBay, os arquivos de configuração do PHP são armazenados em diretórios diferentes dependendo da versão. Por exemplo, os arquivos de configuração do PHP 8.3 estão localizados no diretório /Applications/ServBay/etc/php/8.3
. A seguir estão as localizações detalhadas desses arquivos de configuração:
php.ini
:/Applications/ServBay/etc/php/8.3/php.ini
php-fpm.conf
:/Applications/ServBay/etc/php/8.3/php-fpm.conf
- Arquivos de configuração de carregamento de módulos do PHP:
/Applications/ServBay/etc/php/8.3/conf.d/
Configuração do php.ini
O arquivo php.ini
é o arquivo principal de configuração do PHP, utilizado para definir várias opções de runtime do PHP.
Itens de Configuração Comuns
A seguir estão alguns itens comuns de configuração do php.ini
e como modificá-los:
Modificar limite de memória:
memory_limit = 256M
1Modificar limite de tamanho de upload de arquivos:
upload_max_filesize = 50M post_max_size = 50M
1
2Modificar configuração de fuso horário:
date.timezone = "Asia/Hong_Kong"
1Ativar exibição de erros:
display_errors = On error_reporting = E_ALL
1
2Modificar tempo máximo de execução:
max_execution_time = 300
1
Configuração do php-fpm.conf
O arquivo php-fpm.conf
é utilizado para configurar os parâmetros de execução do PHP-FPM (FastCGI Process Manager).
Itens de Configuração Comuns
A seguir estão alguns itens comuns de configuração do php-fpm.conf
e como modificá-los:
Modificar configurações do pool de processos:
[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
16Ativar log de requisições lentas:
request_slowlog_timeout = 5s slowlog = /Applications/ServBay/logs/php/8.3/slow.log
1
2Modificar caminho do log de erros:
error_log = /Applications/ServBay/logs/php/8.3/errors.log
1
Configuração de Carregamento de Módulos do PHP
Os arquivos de configuração de carregamento de módulos do PHP estão localizados no diretório /Applications/ServBay/etc/php/8.3/conf.d/
. Por exemplo, o arquivo xdebug.ini
é utilizado para configurar a extensão do Xdebug.
Exemplo de xdebug.ini
A seguir está um exemplo de arquivo xdebug.ini
:
[Xdebug]
; Descomente a linha a seguir para habilitar o 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
Reiniciar o PHP
Após modificar os arquivos de configuração do PHP, é necessário reiniciar o serviço PHP para que as mudanças tenham efeito. Você pode fazer isso através da interface de gerenciamento do ServBay ou utilizando a ferramenta de linha de comando servbayctl
.
Reiniciar pela Interface de Gerenciamento do ServBay
- Abra a interface de gerenciamento do ServBay.
- Navegue até
Serviços
. - Encontre o serviço PHP da versão correspondente e clique no botão
Reiniciar
.
Reiniciar pelo servbayctl
Usar a ferramenta de linha de comando servbayctl
para reiniciar o serviço PHP é fácil:
servbayctl restart php 8.3
Resumo
No ServBay, os arquivos de configuração do PHP estão localizados no diretório /Applications/ServBay/etc/php/<version>
, incluindo php.ini
e php-fpm.conf
. Os arquivos de configuração de carregamento de módulos do PHP estão localizados no diretório /Applications/ServBay/etc/php/<version>/conf.d/
. Após modificar esses arquivos de configuração, você pode reiniciar o serviço PHP através da interface de gerenciamento do ServBay ou utilizando a ferramenta de linha de comando servbayctl
para que as mudanças tenham efeito.