Appearance
PHP 8.3 Commands
PHP-FPM (FastCGI Process Manager) handles all PHP processing for Zal Ultra. These commands help you manage the PHP service.
🟠 MEDIUM RISK
Restarting PHP-FPM will briefly interrupt all web requests. Users may see errors for 1-2 seconds during restart.
Table of Contents
Service Management
Check PHP-FPM Status
bash
sudo systemctl status php8.3-fpmPurpose: Shows if PHP-FPM is running and recent activity.
Start PHP-FPM
bash
sudo systemctl start php8.3-fpmStop PHP-FPM
🔴 SERVICE OUTAGE
Stopping PHP-FPM will make Zal Ultra completely non-functional. All pages will show 502 errors.
bash
sudo systemctl stop php8.3-fpmRestart PHP-FPM
🟠 BRIEF INTERRUPTION
Restart causes 1-2 seconds of 502 errors for active users.
bash
sudo systemctl restart php8.3-fpmWhen to use:
- After php.ini changes
- After installing PHP extensions
- Memory issues
Reload PHP-FPM (Graceful)
bash
sudo systemctl reload php8.3-fpmPurpose: Gracefully reloads configuration. Preferred over restart.
Enable on Boot
bash
sudo systemctl enable php8.3-fpmConfiguration
PHP Version Check
bash
php -vShow PHP Info
bash
php -iShow Loaded Modules
bash
php -mCheck Specific Module
bash
php -m | grep -i mysql
php -m | grep -i redis
php -m | grep -i gdConfiguration Files
bash
# Main PHP CLI config
sudo nano /etc/php/8.3/cli/php.ini
# PHP-FPM config
sudo nano /etc/php/8.3/fpm/php.ini
# FPM pool config (important!)
sudo nano /etc/php/8.3/fpm/pool.d/www.confImportant php.ini Settings
bash
# View current settings
php -i | grep memory_limit
php -i | grep max_execution_time
php -i | grep upload_max_filesize
php -i | grep post_max_sizeCommon Settings to Adjust
ini
; /etc/php/8.3/fpm/php.ini
memory_limit = 512M
max_execution_time = 300
upload_max_filesize = 100M
post_max_size = 100M
max_input_vars = 5000After changing php.ini:
bash
sudo systemctl restart php8.3-fpmPerformance Tuning
Check FPM Pool Status
bash
# If status page is enabled
curl http://localhost/status
# Or check processes
ps aux | grep php-fpmCount PHP-FPM Workers
bash
ps aux | grep "php-fpm: pool" | wc -lCheck Memory Usage per Worker
bash
ps -ylC php-fpm8.3 --sort:rssPool Configuration (www.conf)
bash
sudo nano /etc/php/8.3/fpm/pool.d/www.confKey settings:
ini
; Process manager type
pm = dynamic
; Maximum children (adjust based on RAM)
pm.max_children = 50
; Start servers
pm.start_servers = 10
; Min/Max spare servers
pm.min_spare_servers = 5
pm.max_spare_servers = 20
; Max requests before respawn (prevents memory leaks)
pm.max_requests = 500Memory calculation:
- Each PHP-FPM worker uses ~50-100MB
pm.max_children = Available RAM / 100MB- Example: 8GB RAM → max_children = 50-60
Log Management
View PHP-FPM Logs
bash
sudo tail -f /var/log/php8.3-fpm.logView PHP Error Log
bash
# Check where errors go
php -i | grep error_log
# Common location
sudo tail -f /var/log/php_errors.logView Slow Log (if enabled)
bash
sudo tail -f /var/log/php8.3-fpm.slow.logEnable Slow Log
bash
# In /etc/php/8.3/fpm/pool.d/www.conf
slowlog = /var/log/php8.3-fpm.slow.log
request_slowlog_timeout = 5sClear PHP Logs
🟠 CAUTION
This removes log history.
bash
sudo truncate -s 0 /var/log/php8.3-fpm.log
sudo truncate -s 0 /var/log/php_errors.logTroubleshooting
Common Issues
502 Bad Gateway
bash
# Check if PHP-FPM is running
sudo systemctl status php8.3-fpm
# Check socket exists
ls -la /run/php/php8.3-fpm.sock
# Restart PHP-FPM
sudo systemctl restart php8.3-fpmMemory Exhausted
bash
# Increase memory limit
sudo nano /etc/php/8.3/fpm/php.ini
# Set: memory_limit = 512M
sudo systemctl restart php8.3-fpmMax Execution Time
bash
# Increase timeout
sudo nano /etc/php/8.3/fpm/php.ini
# Set: max_execution_time = 300
sudo systemctl restart php8.3-fpmSocket Permission Issues
bash
# Check socket permissions
ls -la /run/php/php8.3-fpm.sock
# Fix in www.conf
listen.owner = www-data
listen.group = www-data
listen.mode = 0660Check PHP Extensions
bash
# Required for Zal Ultra
php -m | grep -E "mysql|redis|gd|curl|mbstring|xml|zip|bcmath"Install Missing Extension
bash
sudo apt install php8.3-mysql php8.3-redis php8.3-gd php8.3-curl php8.3-mbstring php8.3-xml php8.3-zip php8.3-bcmath
sudo systemctl restart php8.3-fpmClear OPcache
bash
# From command line
php -r "opcache_reset();"
# Or restart PHP-FPM
sudo systemctl restart php8.3-fpmQuick Reference Card
| Action | Command |
|---|---|
| Check status | sudo systemctl status php8.3-fpm |
| Start | sudo systemctl start php8.3-fpm |
| Stop | sudo systemctl stop php8.3-fpm |
| Restart | sudo systemctl restart php8.3-fpm |
| Reload | sudo systemctl reload php8.3-fpm |
| PHP version | php -v |
| PHP modules | php -m |
| View logs | sudo tail -f /var/log/php8.3-fpm.log |
| Config (FPM) | /etc/php/8.3/fpm/php.ini |
| Pool config | /etc/php/8.3/fpm/pool.d/www.conf |
