LAMP Optimizer
Comprehensive tool for optimizing and managing LAMP (Linux, Apache/Nginx, MySQL, PHP) stack configurations.
LAMP Stack Optimizer
A comprehensive tool for optimizing and managing LAMP (Linux, Apache/Nginx, MySQL, PHP) stack configurations.
Features
- Automated installation and configuration of LAMP stack
- Component-specific optimization (Nginx, PHP-FPM, MySQL)
- Performance monitoring and analysis
- Configuration backup and rollback
- Cross-platform support (Debian/Ubuntu, RHEL/CentOS)
Installation
Prerequisites
- Bash shell
- Python 3 (for dashboard)
- jq (for JSON processing)
- yq (for YAML processing, optional)
- Root or sudo privileges
Installation Steps
Download the script from the Lambda Softworks Customer Portal:
- Log in to your Lambda Softworks Customer Portal account
- Navigate to the Files section
- Download the lamp-optimizer.sh script
Make the script executable:
chmod +x lamp-optimizer.sh
- Install dependencies:
For Debian/Ubuntu:
sudo apt-get update sudo apt-get install -y python3 jq sysstat
For RHEL/CentOS:
sudo yum install -y python3 jq sysstat
Usage
Basic Commands
- Install LAMP stack:
sudo ./lamp-optimizer.sh --install-stack
- Optimize specific components:
sudo ./lamp-optimizer.sh --optimize nginx,php,mysql
- Analyze performance:
sudo ./lamp-optimizer.sh --analyze-performance
Advanced Options
--auto-optimize
: Automatic optimization based on system analysis--backup
: Create configuration backup before changes--test
: Test configuration before applying--rollback
: Revert to previous configuration
Configuration
Configuration File
# /etc/web-tools-config.yml nginx: worker_processes: auto worker_connections: 2048 keepalive_timeout: 65 fastcgi_cache: true gzip: true ssl: protocols: TLSv1.2 TLSv1.3 ciphers: HIGH:!aNULL:!MD5 php: version: "8.2" memory_limit: 256M max_execution_time: 60 opcache: enabled: true memory_consumption: 128 interned_strings_buffer: 16 fpm: pm: dynamic max_children: 50 start_servers: 5 min_spare_servers: 5 max_spare_servers: 35 mysql: innodb_buffer_pool_size: 1G query_cache_size: 0 max_connections: 150 slow_query_log: true
Logs and Data Storage
Log File Location
/var/log/web-tools/lamp-optimizer.log
Backup Location
/etc/web-tools/backups/
Report Location
/var/log/web-tools/reports/
Cross-Platform Compatibility
Linux Support
- RHEL/CentOS 7+
- Ubuntu 18.04+
- Debian 10+
- Other Linux distributions with systemd
Service Support
- Nginx 1.18+
- PHP-FPM 7.4+
- MySQL 5.7+
Examples
New Server Setup
# Install and optimize LAMP stack sudo ./lamp-optimizer.sh --install-stack --auto-optimize
Performance Optimization
# Analyze current performance sudo ./lamp-optimizer.sh --analyze-performance # Optimize specific components sudo ./lamp-optimizer.sh --optimize nginx,php
Troubleshooting
Common Issues
Permission Errors
- Ensure the script is run with sudo
- Check directory permissions
- Verify user has necessary privileges
Service Issues
- Verify service names in configuration
- Check systemd service status
- Review service logs
Report Generation Issues
- Check log directory permissions
- Verify HTML template access
- Check disk space
Debug Mode
To enable debug logging:
sudo DEBUG=1 ./lamp-optimizer.sh [OPTIONS]