PHP Settings
PHP Settings: Performance Optimization and Configuration for rConfig V8
Section titled “PHP Settings: Performance Optimization and Configuration for rConfig V8”rConfig V8 relies on PHP to execute its core functionality, and proper PHP configuration directly impacts system performance, stability, and the ability to handle large-scale network management operations. Understanding and optimizing key PHP settings ensures rConfig can process extensive configuration files, execute tasks across hundreds of devices simultaneously, and maintain responsive operations under load.
This addresses the challenge of PHP’s default conservative resource limits, which are designed for typical web applications but inadequate for network configuration management systems processing large datasets and long-running background operations. Organizations can leverage PHP tuning to eliminate timeout errors, memory exhaustion failures, and performance bottlenecks.
Understanding Critical PHP Settings
Section titled “Understanding Critical PHP Settings”Memory Limit
Section titled “Memory Limit”The memory_limit
setting defines the maximum amount of memory a single PHP process can consume before being terminated. For rConfig operations, adequate memory allocation is essential when:
- Processing large configuration files from enterprise routers or switches
- Executing compliance checks across thousands of device configurations simultaneously
- Generating comprehensive reports with extensive historical data
- Performing bulk operations like policy assignments across device inventories
- Running backups that aggregate configuration data from entire repositories
Insufficient memory allocation manifests as “Allowed memory size exhausted” errors, typically during configuration downloads, report generation, or bulk operations. These failures interrupt operations and require manual retry, impacting operational efficiency.
Execution Time
Section titled “Execution Time”The max_execution_time
setting controls how long a PHP script can run before PHP automatically terminates it. This protects servers from runaway processes but can prematurely terminate legitimate long-running operations.
For rConfig, execution time becomes critical when:
- Downloading configurations from hundreds of devices in a single task
- Running comprehensive compliance evaluations across large device inventories
- Generating detailed audit reports spanning extended time periods
- Executing system backups that compress large configuration repositories
- Performing database maintenance operations on tables with millions of rows
Insufficient execution time causes tasks to fail mid-operation, leaving partial results and requiring restart. While the queue system mitigates some execution time constraints through background processing, certain operations still require extended PHP execution windows.
Recommended Configuration Values
Section titled “Recommended Configuration Values”Memory Limit Guidelines
Section titled “Memory Limit Guidelines”Memory requirements scale with deployment size and operation complexity. These recommendations assume dedicated rConfig servers where PHP is the primary memory consumer:
Server RAM | Recommended memory_limit | Deployment Size |
---|---|---|
4GB | 3072M (3GB) | Small: < 500 devices |
8GB | 6144M (6GB) | Medium: 500-1,000 devices |
16GB | 12288M (12GB) | Large: 1,000-5,000 devices |
32GB+ | 28672M (28GB) | Enterprise: 10,000+ devices |
Note: These values allocate approximately 75-85% of available RAM to PHP, leaving sufficient memory for the OS, database, and web server processes. Adjust downward if other memory-intensive applications share the server.
Execution Time Guidelines
Section titled “Execution Time Guidelines”Execution time requirements depend on the number of devices managed and the complexity of operations:
Environment Size | Recommended max_execution_time | Rationale |
---|---|---|
Small (< 100 devices) | 300 seconds (5 minutes) | Most operations complete within this window |
Medium (100-500 devices) | 600 seconds (10 minutes) | Bulk operations require extended processing |
Large (500-1,500 devices) | 900 seconds (15 minutes) | Comprehensive tasks span many devices |
Enterprise (1,500+ devices) | 1200 seconds (20 minutes) | Large-scale operations need maximum time |
Modifying PHP Settings
Section titled “Modifying PHP Settings”Configuration File Method
Section titled “Configuration File Method”The recommended approach for PHP configuration modifies the php.ini
file directly. This ensures settings apply consistently across all PHP operations including web requests, command-line scripts, and queue workers.
Locate the active php.ini file:
php -i | grep "Loaded Configuration File"
This command displays the path to the active configuration file. Common locations include:
- Ubuntu/Debian:
/etc/php/8.3/fpm/php.ini
or/etc/php/8.3/apache2/php.ini
- CentOS/RHEL/Rocky/AlmaLinux:
/etc/php.ini
Important considerations:
- PHP may use different
php.ini
files for web (Apache/Nginx) versus command-line operations - Modify the web server PHP configuration for web interface operations
- Modify the CLI PHP configuration if running artisan commands directly
- PHP-FPM typically requires configuration in the FPM-specific php.ini
Step-by-Step Configuration Procedure
Section titled “Step-by-Step Configuration Procedure”Step 1: Identify PHP version and configuration file location
php -vphp -i | grep "Loaded Configuration File"
Note the PHP version (e.g., 8.3) and configuration file path.
Step 2: Create configuration backup
php -vphp -i | grep "Loaded Configuration File"
Note the PHP version (e.g., 8.3) and configuration file path.
sudo cp /etc/php/8.3/fpm/php.ini /etc/php/8.3/fpm/php.ini.backup.$(date +%Y%m%d)
If using Apache instead of PHP-FPM, also backup the Apache configuration:
sudo cp /etc/php/8.3/apache2/php.ini /etc/php/8.3/apache2/php.ini.backup.$(date +%Y%m%d)
Step 2: Create configuration backup
sudo cp /etc/php/8.3/fpm/php.ini /etc/php/8.3/fpm/php.ini.backup.$(date +%Y%m%d)
If using Apache instead of PHP-FPM, also backup the Apache configuration:
sudo cp /etc/php/8.3/apache2/php.ini /etc/php/8.3/apache2/php.ini.backup.$(date +%Y%m%d)
Step 3: Edit the PHP configuration file
sudo nano /etc/php/8.3/fpm/php.ini
Step 4: Locate and modify memory_limit
Press Ctrl+W
, type memory_limit
, press Enter. Find the line:
memory_limit = 128M
Change to your desired value based on server RAM, in this case 6G may be appropriate:
memory_limit = 6144M
Step 5: Locate and modify max_execution_time
Press Ctrl+W
, type max_execution_time
, press Enter. Find the line:
max_execution_time = 30
Change to your desired value based on deployment size:
max_execution_time = 600
Step 6: Save changes
Press Ctrl+O
to write changes, Enter
to confirm, Ctrl+X
to exit.
Step 7: Restart PHP and web server
For PHP-FPM with Nginx:
sudo systemctl restart php8.3-fpmsudo systemctl restart nginx
For Apache:
sudo systemctl restart apache2
Step 8: Verify configuration changes
php -i | grep memory_limitphp -i | grep max_execution_time
Step 1: Identify PHP version and configuration file location
php -vphp -i | grep "Loaded Configuration File"
Note the PHP version and configuration file path.
Step 2: Create configuration backup
sudo cp /etc/php.ini /etc/php.ini.backup.$(date +%Y%m%d)
Step 3: Edit the PHP configuration file
sudo vi /etc/php.ini
Step 4: Locate and modify memory_limit
Press /
, type memory_limit
, press Enter. Press i
to enter insert mode. Find the line:
memory_limit = 128M
Change to your desired value:
memory_limit = 6144M
Step 5: Locate and modify max_execution_time
Press Esc
to exit insert mode. Press /
, type max_execution_time
, press Enter. Press i
to enter insert mode. Find the line:
max_execution_time = 30
Change to your desired value:
max_execution_time = 600
Step 6: Save changes
Press Esc
, type :wq
, press Enter to save and quit.
Step 7: Restart PHP and web server
For PHP-FPM with Nginx:
sudo systemctl restart php-fpmsudo systemctl restart nginx
For Apache:
sudo systemctl restart httpdsudo systemctl restart php-fpm
Step 8: Verify configuration changes
php -i | grep memory_limitphp -i | grep max_execution_time
Verifying Configuration Changes
Section titled “Verifying Configuration Changes”After modifying PHP settings and restarting services, verification ensures changes took effect correctly:
Command-Line Verification
Section titled “Command-Line Verification”Check settings via command-line PHP:
php -i | grep memory_limitphp -i | grep max_execution_time
This verifies settings for CLI operations and queue workers.
Verification Through rConfig
Section titled “Verification Through rConfig”An operational test confirms settings apply during actual rConfig operations:
- Navigate to System Settings >> System Optimization and review system information
- Attempt a resource-intensive operation like generating a large report
- Monitor for memory or timeout errors in Application Log
- If operations complete successfully without errors, configuration is adequate
Troubleshooting Configuration Issues
Section titled “Troubleshooting Configuration Issues”Symptom: Changes Not Applied After Restart
Section titled “Symptom: Changes Not Applied After Restart”Diagnosis: Verify correct php.ini file was modified and services restarted.
Possible Causes:
- Modified php.ini for CLI instead of web server
- Modified wrong PHP version’s configuration
- Web server or PHP-FPM not restarted after changes
- Syntax error in php.ini preventing PHP from loading
Resolution Steps:
-
Verify which php.ini file is active for web requests:
Terminal window php -i | grep "Loaded Configuration File" -
Check if PHP-FPM or web server is running:
Terminal window sudo systemctl status php-fpmsudo systemctl status nginx -
Review PHP error logs for configuration errors:
Terminal window sudo tail -50 /var/log/php-fpm/error.log -
Test PHP configuration syntax:
Terminal window php -i > /dev/null -
If syntax errors exist, restore backup and retry modifications
Symptom: Operations Still Failing with Memory Errors
Section titled “Symptom: Operations Still Failing with Memory Errors”Diagnosis: Memory allocation insufficient for operation scale or memory leak present.
Possible Causes:
- Configuration processing requires more memory than allocated
- Memory leak in PHP extensions or rConfig code
- Multiple concurrent operations exhausting available memory
- Database queries returning extremely large result sets
Resolution Steps:
- Review System Logs for specific memory exhaustion messages
- Identify which operation causes the error (device count, report size)
- Increase memory_limit incrementally (add 2-4GB)
- If problem persists despite large allocation, contact rConfig support for memory profiling
- Consider breaking large operations into smaller batches
Symptom: Queue Workers Ignore PHP Configuration
Section titled “Symptom: Queue Workers Ignore PHP Configuration”Diagnosis: Queue workers use separate PHP configuration or process management settings.
Possible Causes:
- Queue workers run under different PHP configuration
- Supervisor process manager has its own timeout settings
- Queue worker command-line PHP uses different php.ini
- Environment variables override php.ini settings
Resolution Steps:
-
Verify CLI PHP configuration:
Terminal window php -i | grep "Loaded Configuration File" -
Check if different from web PHP configuration, modify both files identically
-
Review Supervisor configuration for timeout settings in
/etc/supervisor/conf.d/rconfig-horizon.conf
-
Restart Horizon queue workers:
Terminal window php /var/www/html/rconfig8/current/artisan horizon:terminatesudo systemctl restart rconfig-horizon
Best Practices
Section titled “Best Practices”Security
Section titled “Security”Delete phpinfo files immediately: The phpinfo()
function exposes comprehensive server configuration including database credentials, API keys, and security-sensitive settings. Never leave phpinfo.php files accessible on production servers. If verification is needed, delete the file within minutes of creation.
Balance resource allocation with system stability: While generous memory limits improve rConfig performance, excessively high limits allow runaway processes to consume all available RAM, potentially crashing the entire server. Set memory_limit to 75-85% of available RAM, ensuring the operating system retains sufficient resources for stability.
Monitor for resource exhaustion attacks: Malicious actors may attempt to trigger resource-intensive operations to exhaust server memory or CPU. Monitor for unusual patterns of resource consumption and implement rate limiting on API endpoints if exposed.
Performance
Section titled “Performance”Align PHP settings with deployment scale: As device inventories grow, revisit PHP configuration quarterly to ensure settings remain adequate. A memory_limit appropriate for 100 devices will prove insufficient when managing 1,000 devices.
Prioritize queue system over execution time increases: For truly large-scale operations, rely on the queue system rather than continually increasing max_execution_time. Queue workers process jobs independently with sophisticated retry logic, providing better scalability than extended synchronous execution.
Monitor actual resource usage: Use tools like top
, htop
, or monitoring dashboards to observe actual PHP memory consumption during peak operations. This empirical data guides configuration adjustments more accurately than estimates.
Restart PHP-FPM regularly on high-volume systems: PHP-FPM workers can accumulate memory over time (memory bloat). Schedule PHP-FPM restarts during maintenance windows (weekly or monthly) on high-volume deployments to maintain optimal performance.
Organization
Section titled “Organization”Document configuration changes: Maintain internal documentation noting PHP configuration values, when they were changed, and why. This prevents confusion during troubleshooting and helps with capacity planning.
Version control configuration files: Store copies of php.ini and other configuration files in version control systems. This enables rapid restoration after server rebuilds and provides audit trails of configuration evolution.
Test configuration changes in non-production first: Whenever possible, validate PHP configuration changes in staging or test environments before applying to production. This identifies issues before they impact operations.
Maintenance
Section titled “Maintenance”Review PHP configuration during major version upgrades: PHP version upgrades (e.g., 7.4 to 8.3) often introduce different default settings or require configuration migration. After PHP upgrades, verify all customizations remain in effect.
Coordinate with system updates: Operating system updates sometimes replace customized configuration files with defaults. After OS updates, verify PHP settings remain as configured and reapply customizations if necessary.
Monitor for PHP deprecation warnings: As PHP evolves, certain functions and features are deprecated. Review PHP error logs regularly for deprecation warnings that may require code or configuration updates in future PHP versions.
Related Documentation
Section titled “Related Documentation”- System Requirements - Hardware and software prerequisites including PHP version requirements
- Installation Guide - Initial rConfig setup including PHP configuration
- Horizon Queue Manager - Understanding background job processing that relies on PHP configuration
- System Logs - Viewing PHP errors and exceptions
- Performance Tuning - Comprehensive performance optimization strategies
Quick Reference
Section titled “Quick Reference”Common Memory Limit Values
Section titled “Common Memory Limit Values”memory_limit | Suitable For |
---|---|
128M | Very small deployments (< 50 devices) |
512M | Small deployments (50-200 devices) |
1024M (1GB) | Medium deployments (200-500 devices) |
2048M (2GB) | Large deployments (500-1,000 devices) |
4096M (4GB) | Very large deployments (1,000-5,000 devices) |
8192M (8GB) | Enterprise deployments (5,000+ devices) |
Common Execution Time Values
Section titled “Common Execution Time Values”max_execution_time | Suitable For |
---|---|
300 (5 minutes) | Small deployments (< 100 devices) |
600 (10 minutes) | Medium deployments (100-500 devices) |
900 (15 minutes) | Large deployments (500-1,500 devices) |
1200 (20 minutes) | Enterprise deployments (1,500+ devices) |
Configuration File Locations
Section titled “Configuration File Locations”Operating System | PHP-FPM | Apache | CLI |
---|---|---|---|
Ubuntu/Debian | /etc/php/8.3/fpm/php.ini | /etc/php/8.3/apache2/php.ini | /etc/php/8.3/cli/php.ini |
CentOS/RHEL/Rocky/AlmaLinux | /etc/php.ini | /etc/php.ini | /etc/php.ini |
Service Restart Commands
Section titled “Service Restart Commands”sudo systemctl restart php8.3-fpmsudo systemctl restart nginxsudo systemctl restart apache2sudo systemctl restart httpdsudo php artisan rconfig:clear-all
Summary
Section titled “Summary”Proper PHP configuration is fundamental to rConfig V8 performance and stability. Memory limits and execution time settings must scale with deployment size to prevent timeout errors, memory exhaustion failures, and operational interruptions. Organizations managing hundreds or thousands of network devices require generous resource allocation to support concurrent configuration downloads, compliance evaluations, and report generation.
Key takeaways for effective PHP configuration:
- Allocate 75-85% of server RAM to PHP memory_limit on dedicated rConfig servers
- Scale execution time with device count, but rely on queue system for truly large operations
- Modify php.ini directly rather than using .htaccess for consistent application across all PHP operations
- Always create backups before modifying configuration to enable rapid recovery from errors
- Verify changes using both command-line and web interface testing to confirm application
Regular review and adjustment of PHP settings as deployments grow ensures rConfig maintains reliable, performant operations at scale. When configuration adjustments prove insufficient, contact rConfig support for assistance with performance profiling and advanced optimization strategies.