Modifica delle configurazioni PHP
ServBay viene fornito con un ambiente PHP e offre opzioni di configurazione flessibili. Questo documento illustra in dettaglio come modificare le configurazioni PHP in ServBay, inclusa la posizione dei file php.ini
e php-fpm.conf
e le impostazioni di configurazione comuni. A seconda della versione di PHP, questi file si trovano nella directory /Applications/ServBay/etc/php/<version>
. Inoltre, i file di configurazione del caricamento dei moduli PHP (come xdebug.ini
) si trovano nella directory /Applications/ServBay/etc/php/<version>/conf.d
.
Panoramica
In ServBay, i file di configurazione di PHP sono memorizzati in diverse directory a seconda della versione. Ad esempio, i file di configurazione di PHP 8.3 si trovano nella directory /Applications/ServBay/etc/php/8.3
. Di seguito sono indicate le posizioni dettagliate di questi file di configurazione:
php.ini
:/Applications/ServBay/etc/php/8.3/php.ini
php-fpm.conf
:/Applications/ServBay/etc/php/8.3/php-fpm.conf
- File di configurazione del caricamento dei moduli PHP:
/Applications/ServBay/etc/php/8.3/conf.d/
Configurazione php.ini
Il file php.ini
è il principale file di configurazione di PHP, utilizzato per impostare varie opzioni di runtime di PHP.
Impostazioni comuni
Di seguito sono riportate alcune impostazioni comuni del file php.ini
e come modificarle:
Modifica del limite di memoria:
memory_limit = 256M
1Modifica del limite di dimensione dei file caricati:
upload_max_filesize = 50M post_max_size = 50M
1
2Modifica dell'impostazione del fuso orario:
date.timezone = "Asia/Hong_Kong"
1Abilitare la visualizzazione degli errori:
display_errors = On error_reporting = E_ALL
1
2Modifica del tempo massimo di esecuzione:
max_execution_time = 300
1
Configurazione php-fpm.conf
Il file php-fpm.conf
è utilizzato per configurare i parametri di esecuzione di PHP-FPM (FastCGI Process Manager).
Impostazioni comuni
Di seguito sono riportate alcune impostazioni comuni del file php-fpm.conf
e come modificarle:
Modifica delle impostazioni del pool di processi:
[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
16Abilitare il log delle richieste lente:
request_slowlog_timeout = 5s slowlog = /Applications/ServBay/logs/php/8.3/slow.log
1
2Modifica del percorso del file di log degli errori:
error_log = /Applications/ServBay/logs/php/8.3/errors.log
1
Configurazione del caricamento dei moduli PHP
I file di configurazione del caricamento dei moduli PHP si trovano nella directory /Applications/ServBay/etc/php/8.3/conf.d/
. Ad esempio, il file xdebug.ini
è utilizzato per configurare l'estensione Xdebug.
Esempio di xdebug.ini
Di seguito è riportato un esempio di file 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
Riavvio di PHP
Dopo aver modificato i file di configurazione di PHP, è necessario riavviare il servizio PHP affinché le modifiche abbiano effetto. È possibile riavviare tramite l'interfaccia di gestione di ServBay oppure utilizzare lo strumento da riga di comando servbayctl
.
Riavvio tramite l'interfaccia di gestione di ServBay
- Aprire l'interfaccia di gestione di ServBay.
- Navigare a
Servizi
. - Trova il servizio PHP corrispondente alla versione e clicca sul pulsante
Riavvia
.
Riavvio tramite servbayctl
Utilizzando lo strumento da riga di comando servbayctl
, è possibile riavviare il servizio PHP in modo conveniente:
servbayctl restart php 8.3
Conclusione
In ServBay, i file di configurazione di PHP si trovano nella directory /Applications/ServBay/etc/php/<version>
, inclusi php.ini
e php-fpm.conf
. I file di configurazione del caricamento dei moduli PHP si trovano nella directory /Applications/ServBay/etc/php/<version>/conf.d/
. Dopo aver modificato questi file di configurazione, è possibile riavviare il servizio PHP tramite l'interfaccia di gestione di ServBay o utilizzando lo strumento da riga di comando servbayctl
affinché le modifiche abbiano effetto.