DOCUMENTATION UPDATES: README.md changes: - Added php-optimizer.sh to performance modules section - Added 3 new libraries: php-detector.sh, php-analyzer.sh, php-config-manager.sh - Added comprehensive PHP Configuration Optimizer feature description - Updated with all capabilities (7-day analysis, OPcache tuning, auto-backup, rollback) DEVELOPMENT_LOG.md (NEW): - Comprehensive tracking document for ALL development work - Detailed documentation of PHP optimizer (Dec 2-3, 2025) - Component breakdown: 4 files, 2,960 lines, 45 functions - Complete workflow documentation for Option 4 - Safety features and testing status documented - Git commit history tracked - Development guidelines established - Placeholder sections for Nov 21-30 work to be filled in DEVELOPMENT GUIDELINES ESTABLISHED: - NO AI attribution in commits (per user instructions) - Update DEVELOPMENT_LOG.md with every change - Track file statistics and testing status - Document all git commits and decisions This establishes proper ongoing documentation practices going forward.
8.8 KiB
Server Toolkit Development Log
Purpose: Comprehensive tracking of ALL development work, changes, and decisions Last Updated: 2025-12-03
December 2-3, 2025: PHP Configuration Optimizer (Complete)
Summary
Built comprehensive PHP configuration optimization system with 7 phases of development.
Components Created
1. lib/php-detector.sh (428 lines, 17 functions)
Purpose: Detect and locate all PHP configuration files across control panels Created: December 2, 2025
Functions:
detect_php_version_for_domain()- Detect PHP version per domaindetect_php_binary()- Find PHP binary pathfind_php_ini()- Locate php.ini files (4 priority levels)find_fpm_pool_config()- Find PHP-FPM pool configsfind_all_php_configs()- Comprehensive config discoveryget_opcache_config_file()- Locate OPcache configs- 11 additional detection functions
Control Panel Support:
- cPanel (ea-php, MultiPHP)
- InterWorx (SiteWorx)
- Plesk
- Standalone Apache
2. lib/php-analyzer.sh (940 lines, 14 functions)
Purpose: Analyze PHP performance metrics and generate recommendations Created: December 2, 2025
Functions:
get_opcache_stats()- Extract OPcache statisticscalculate_opcache_hit_rate()- Calculate hit percentagecheck_max_children_errors()- Scan 7-day error logsanalyze_php_memory_usage()- Memory consumption analysisget_process_manager_stats()- PHP-FPM pm statsrecommend_max_children()- Calculate optimal max_childrenrecommend_memory_limit()- Calculate optimal memory_limitrecommend_opcache_settings()- OPcache tuning recommendations- 6 additional analysis functions
Key Features:
- 7-day historical error log analysis
- OPcache hit rate calculation with division-by-zero protection
- Intelligent max_children recommendations based on actual errors
- Memory limit optimization based on real usage patterns
3. lib/php-config-manager.sh (509 lines, 14 functions)
Purpose: Backup, restore, and modify PHP configurations safely Created: December 2, 2025
Functions:
backup_user_php_configs()- Create timestamped backups with metadatarestore_from_backup()- Restore from backup with verificationlist_backups()- Display all available backupsdelete_backup()- Remove backup directoriesmodify_fpm_pool_setting()- Modify PHP-FPM pool settings via sedmodify_php_ini_setting()- Modify php.ini settingsapply_fpm_pool_settings()- Batch apply multiple settingsrestart_php_fpm()- Restart PHP-FPM servicereload_php_fpm()- Graceful reload (zero downtime)verify_php_fpm_running()- Verify service status- 4 additional configuration functions
Backup System:
- Location:
/root/server-toolkit/backups/php/ - Format: Timestamped directories with metadata
- Preserves directory structure and permissions
- Tracks all backed up files with original paths
4. modules/performance/php-optimizer.sh (1,083 lines)
Purpose: Interactive menu-driven PHP optimization tool Created: December 2, 2025
Menu Options:
- Analyze All Domains - Comprehensive server-wide analysis
- Analyze Single Domain - Per-domain analysis
- Show OPcache Statistics - OPcache performance metrics
- Optimize Domain - Main action menu with apply workflow
- View PHP Error Logs - Error log viewer with filtering
- PHP Version Summary - Version distribution report
- Find Configuration Files - Config file discovery tool
- Backup Configurations (b) - Manual backup creation
- Restore from Backup (r) - Rollback capability
- Quit
Option 4 Workflow (Optimize Domain):
- Select domain from list
- Display current configuration
- Show recommendations with explanations
- Ask: "Apply these recommendations? (y/n)"
- If yes: Create auto-backup (timestamped)
- Apply changes to PHP-FPM pool config
- Ask: "Restart PHP-FPM now? (y/n)"
- If yes: Gracefully reload PHP-FPM (zero downtime)
- Verify service is running
- Display backup location for rollback
Safety Features:
- User confirmation required for ALL changes
- Auto-backup BEFORE any modifications
- Graceful reload (not restart) for zero downtime
- Verification that service is running after reload
- Clear rollback instructions with backup location
- No automatic changes without explicit approval
Integration (December 3, 2025)
Main Menu Integration
File: launcher.sh
Location: Performance & Diagnostics → Option 9
Menu Path:
Main Menu
└─ (4) Performance & Diagnostics
└─ (9) PHP Configuration Optimizer
Changes Made:
- Added menu option 9: "PHP Configuration Optimizer"
- Updated handler function to call
php-optimizer.sh - Shifted existing options 9-11 to 10-12
- Validated syntax with
bash -n
Git Commits
- Phase 1: Create lib/php-detector.sh (detection functions)
- Phase 2: Create lib/php-analyzer.sh (analysis engine)
- Phase 3: Create modules/performance/php-optimizer.sh (main script)
- Phase 4: Implement backup/restore system with PHP-FPM restart
- Phase 5 & 6: Implement apply/action menu with auto-backup and PHP-FPM restart
- Phase 7: Integrate PHP Configuration Optimizer into main menu
Note: Removed AI attribution markers from commits per user instructions.
Documentation Created
PHP_OPTIMIZER_PLAN.md- Initial planning documentPHP_METRICS_COMPREHENSIVE.md- Comprehensive metrics trackingPHP_CONFIG_LOCATIONS_COMPLETE.md- Config file locations by panelSESSION_SUMMARY.md- Session work summaryPHP_OPTIMIZER_COMPLETE.md- Completion documentationDEVELOPMENT_LOG.md- This file (NEW!)
Testing Status
- ✅ Syntax validation complete (all files pass
bash -n) - ✅ Logic validation complete (division-by-zero protection, error handling)
- ✅ Path resolution verified
- ✅ Menu integration tested
- ⏳ Pending: Live server testing with real domains
Metrics Tracked
Per-Domain PHP Settings:
pm.max_children- FPM process limitpm.start_servers- Initial processespm.min_spare_servers- Minimum idle processespm.max_spare_servers- Maximum idle processespm.max_requests- Process recycling thresholdmemory_limit- PHP script memory capupload_max_filesize- Upload size limitpost_max_size- POST data limitmax_execution_time- Script timeoutmax_input_time- Input parsing timeout
OPcache Settings:
opcache.memory_consumption- OPcache memory allocationopcache.interned_strings_buffer- String storage bufferopcache.max_accelerated_files- Cached file limitopcache.enable- OPcache on/offopcache.revalidate_freq- Cache validation frequency
Performance Metrics:
- OPcache hit rate (hits / (hits + misses))
- max_children error frequency (7-day history)
- Active PHP-FPM processes
- Memory consumption per process
- Process manager type (static/dynamic/ondemand)
File Statistics
Total Lines of Code: 2,960 lines
- lib/php-detector.sh: 428 lines
- lib/php-analyzer.sh: 940 lines
- lib/php-config-manager.sh: 509 lines
- modules/performance/php-optimizer.sh: 1,083 lines
Total Functions: 45 exported functions
- php-detector.sh: 17 functions
- php-analyzer.sh: 14 functions
- php-config-manager.sh: 14 functions
Future Enhancements (Planned)
- MySQL Config Optimizer - Similar system for MySQL/MariaDB tuning
- Redis/Memcached Setup - Object caching setup scripts
- Apache/Nginx Optimizer - Web server tuning (revisit later)
Not Planned:
- CDN integration (user declined)
- SSL/TLS optimizer (user declined)
November 21-30, 2025: (Previous Work - Need to Fill In)
TODO: Document all work from November 21-30 including:
- enable-cphulk.sh bug fixes (6 bugs fixed)
- live-attack-monitor color code fixes
- SCRIPT_DIR path calculation fixes
- bot-analyzer optimizations
- Any other modules created or modified
November 20, 2025: (Last Documented Work)
TODO: Pull from previous documentation what was done on this date.
Development Guidelines
Git Commit Messages
- NO AI attribution markers (per user instructions as of Dec 3, 2025)
- Remove "🤖 Generated with Claude Code"
- Remove "Co-Authored-By: Claude noreply@anthropic.com"
- Use clear, descriptive commit messages
- Include technical details and impact
Documentation Standards
- Update DEVELOPMENT_LOG.md with EVERY change
- Update README.md for user-facing features
- Create detailed docs/ files for complex features
- Track file statistics (lines, functions)
- Document all git commits
- Record testing status
Code Standards
- Follow CODING_GUIDELINES.md
- Syntax validation with
bash -nbefore commit - Export all library functions
- Proper error handling and user confirmations
- No automatic changes without user approval
- Graceful service reloads (not restarts)
Last Updated: 2025-12-03 21:45 UTC Next Update: After next development session