Commit Graph

4 Commits

Author SHA1 Message Date
cschantz 90b68bf47b Add complete PHP configuration file locations for all control panels
DOCUMENTATION: Comprehensive PHP config hierarchy across all platforms

CRITICAL ADDITION - All Possible php.ini Locations:

**Priority 1 (HIGHEST) - Per-Directory:**
- .user.ini (PHP-FPM, per-directory, reloads every 5min)
- .htaccess with php_value (mod_php ONLY, usually ignored)
- ~/public_html/.user.ini (most common)
- ~/public_html/subdirectory/.user.ini (cascading)

**Priority 2 - User-Specific:**
- ~/public_html/php.ini (some control panels)
- ~/.php/8.2/php.ini (cPanel MultiPHP style)
- ~/etc/php82/php.ini (InterWorx style)
- ~/php.ini (legacy home directory)

**Priority 3 - Pool-Specific:**
- /opt/cpanel/ea-php82/root/etc/php.ini (cPanel EA-PHP)
- /opt/cpanel/ea-php82/root/etc/php.d/*.ini (additional, alphabetical)
- /opt/alt/php82/etc/php.ini (CloudLinux Alt-PHP)
- /var/www/vhosts/system/domain/etc/php.ini (Plesk)
- /home/user/var/domain/etc/php.ini (InterWorx)

**Priority 4 (LOWEST) - System-Wide:**
- /etc/php.ini (global fallback)

**Coverage by Control Panel:**
 cPanel with EA-PHP (most common, fully mapped)
 CloudLinux with Alt-PHP (fully mapped)
 Plesk (all locations documented)
 InterWorx (domain-specific paths)
 DirectAdmin (user/domain hierarchy)
 No control panel (standard paths)

**Universal Detection Function:**
find_all_php_configs() - Scans ALL possible locations
- Checks 15+ location patterns
- Returns priority-ordered list
- Works across all control panels
- Handles version-specific paths

**Effective Setting Detection:**
Method 1: Query PHP directly (MOST ACCURATE!)
  su -s /bin/bash $user -c "php -r 'echo ini_get("setting");'"

Method 2: Parse hierarchy (fallback)
  Priority 4 → 3 → 2 → 1 (higher overrides lower)

**Key Discoveries:**
- .user.ini overrides EVERYTHING (highest priority!)
- .htaccess php_value only works with mod_php (NOT PHP-FPM!)
- cPanel creates user configs in ~/.php/VERSION/php.ini
- public_html/php.ini exists on some configurations
- Multiple .ini files loaded alphabetically in php.d/

**Detection Commands:**
- Find all: find / -name "php.ini" -type f
- Find .user.ini: find /home -name ".user.ini"
- Get effective: php -r "echo ini_get('setting');"
- List loaded: php --ini

This ensures optimizer finds ALL configs affecting each domain!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 19:45:53 -05:00
cschantz b103845765 Add comprehensive session summary documentation
DOCUMENTATION: Complete development session summary and status

SESSION OVERVIEW:
- 13 git commits with detailed messages
- 9 critical bugs fixed
- 1,098 lines of documentation added
- 70+ PHP metrics identified
- Performance: 50-200x improvements in key areas

COMMITS SUMMARY:
 PHP metrics documentation (70+ settings)
 PHP optimizer planning (4-phase implementation)
 enable-cphulk.sh fixes (6 bugs)
 Live-attack-monitor enhancements
 Color code bug prevention
 Coding guidelines
 Attack detection library (26 patterns)
 Performance optimizations (23 subprocess eliminations)

DOCUMENTATION CREATED:
1. CODING_GUIDELINES.md - Best practices, prevention strategies
2. PHP_OPTIMIZER_PLAN.md - Complete architecture & implementation
3. PHP_METRICS_COMPREHENSIVE.md - 70+ settings with detection methods
4. SESSION_SUMMARY.md - This comprehensive summary

FEATURES COMPLETED:
 Live Attack Monitor (enhanced, auto-blocking, compact mode)
 Enable cPHulk Script (6 bugs fixed, fully functional)
 Attack Detection Library (26 patterns, optimized)
 Prevention Strategies (cecho helper, guidelines)

TESTING STATUS:
 Live-attack-monitor: Fully tested and working
 IPset timeouts: Verified countdown working
 Auto-blocking: Confirmed functional
 enable-cphulk.sh: Fixed but needs cPanel server testing

NEXT STEPS PLANNED:
Phase 1: lib/php-detector.sh (detection logic)
Phase 2: lib/php-analyzer.sh (analysis engine)
Phase 3: modules/performance/php-optimizer.sh (main script)
Phase 4: Integration with live-attack-monitor

METRICS FOR PHP OPTIMIZER:
- Memory settings: 7 metrics
- Execution/timeout: 4 metrics
- PHP-FPM pool: 15 metrics (CRITICAL!)
- OPcache: 12 metrics (MASSIVE IMPACT!)
- Session: 6 metrics
- Security: 6 metrics
- APCu: 5 metrics
- Total: 70+ comprehensive metrics

USER FEEDBACK ADDRESSED:
 Color code bugs (cecho + guidelines)
 Prevention strategies documented
 Auto-blocking verified working
 Performance optimization completed

REPOSITORY STATUS: Clean, documented, ready for implementation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com)
2025-12-02 19:40:21 -05:00
cschantz 7149377e09 Add comprehensive PHP metrics tracking documentation
DOCUMENTATION: Complete guide to PHP configuration hierarchy and metrics

CRITICAL ADDITIONS:
1. PHP Config Hierarchy (.user.ini > pool php.ini > global)
2. How to determine which config takes effect
3. 70+ PHP settings to track with explanations

COMPREHENSIVE METRICS COVERAGE:

**Memory Settings:**
- memory_limit, upload_max_filesize, post_max_size
- max_input_vars, realpath_cache_size
- Detection: memory exhausted errors, upload failures

**PHP-FPM Pool Settings (MOST CRITICAL!):**
- pm (static/dynamic/ondemand modes)
- pm.max_children, pm.start_servers, pm.min/max_spare_servers
- pm.max_requests, pm.process_idle_timeout
- request_terminate_timeout, request_slowlog_timeout
- Detection: max_children reached errors, slow logs

**OPcache (MASSIVE PERFORMANCE!):**
- opcache.enable, opcache.memory_consumption
- opcache.max_accelerated_files
- opcache.jit, opcache.jit_buffer_size (PHP 8+)
- Hit rate calculation, cache effectiveness

**Execution & Timeout:**
- max_execution_time, max_input_time
- default_socket_timeout
- Detection: timeout errors

**Session Management:**
- session.save_handler (files/redis/memcached)
- session.gc_maxlifetime
- Performance impact analysis

**Security Settings:**
- disable_functions, open_basedir
- display_errors (MUST be Off in production!)
- allow_url_include prevention

**APCu Cache:**
- apc.shm_size, apc.ttl
- User cache tracking

**Detection Commands:**
- Find all php.ini files affecting domain
- Get effective settings hierarchy
- Check opcache hit rates
- Find max_children errors
- Track slow requests
- Calculate memory per process

**Per-Domain Metrics Matrix:**
Complete YAML template showing all tracked metrics,
live stats, issue detection, and recommendations

This documentation enables intelligent optimization with
precise detection and actionable recommendations!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 19:37:24 -05:00
cschantz 18a5c6356e Add comprehensive PHP & Server Optimizer planning document
FEATURE PLANNING: PHP-FPM and server-wide optimization system

OVERVIEW:
Intelligent analyzer that scans all domains, detects PHP configs,
analyzes usage patterns, and provides one-click optimization with
automatic backups and safety checks.

LEVERAGES EXISTING INFRASTRUCTURE:
- user-manager.sh: Domain/user detection (70% of work done)
- system-detect.sh: Control panel detection
- optimize-ct-limit.sh: Traffic analysis model
- get_user_log_files(): Log location mapping

CORE CAPABILITIES:
1. Detect all PHP-FPM pool configs per domain
2. Find php.ini hierarchy (.user.ini, local, global)
3. Analyze memory usage, traffic patterns, error logs
4. Calculate optimal pm.max_children, memory_limit, opcache
5. Detect issues: max_children reached, memory exhausted, slow requests
6. Provide actionable recommendations with safety checks
7. One-click apply with automatic backups

IMPLEMENTATION PHASES:
- Phase 1: lib/php-detector.sh (detection logic)
- Phase 2: lib/php-analyzer.sh (analysis engine)
- Phase 3: modules/performance/php-optimizer.sh (main script)
- Phase 4: Integration with live-attack-monitor

TRACKED METRICS:
- pm.max_children, pm.start_servers, pm.min/max_spare_servers
- memory_limit, max_execution_time, upload_max_filesize
- opcache settings, hit rates, memory consumption
- Process counts, memory usage, CPU patterns
- Error rates, slow request logs

NEXT: Expand metrics tracking and begin Phase 1 implementation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 19:34:04 -05:00