MySQL, Apache2 MPM & PHP 8.1 Optimized Settings
[mysqld]
# ═══════════════════════════════════════════════════
# 🔧 BASIC SETTINGS
# ═══════════════════════════════════════════════════
port = 3306
# ═══════════════════════════════════════════════════
# 💾 MEMORY SETTINGS
# ═══════════════════════════════════════════════════
key_buffer_size = 256M
innodb_buffer_pool_size = 512M
max_allowed_packet = 256M
tmp_table_size = 128M
max_heap_table_size = 128M
# ═══════════════════════════════════════════════════
# 🔗 CONNECTION SETTINGS
# ═══════════════════════════════════════════════════
max_connections = 500
max_connect_errors = 1000000
thread_cache_size = 100
thread_stack = 512K
# ═══════════════════════════════════════════════════
# 📊 BUFFER SETTINGS
# ═══════════════════════════════════════════════════
sort_buffer_size = 4M
read_buffer_size = 4M
read_rnd_buffer_size = 4M
join_buffer_size = 4M
myisam_sort_buffer_size = 8M
net_buffer_length = 16M
innodb_log_buffer_size = 64M
# ═══════════════════════════════════════════════════
# 🚀 INNODB SETTINGS
# ═══════════════════════════════════════════════════
innodb_log_file_size = 128M
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table = 1
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_thread_concurrency = 0
innodb_flush_method = O_DIRECT
# ═══════════════════════════════════════════════════
# ⚙️ OTHER SETTINGS
# ═══════════════════════════════════════════════════
performance_schema = ON
big-tables = ON
myisam-recover-options = BACKUP
max_binlog_size = 100M
sql_mode = NO_ENGINE_SUBSTITUTION
table_open_cache = 4000
log_error = /var/log/mysql/error.log
File Location: /etc/mysql/mysql.conf.d/mysqld.cnf or /etc/my.cnf
Restart Command: sudo systemctl restart mysql
Check Status: sudo systemctl status mysql
<VirtualHost *:80>
ServerName jazila-traders.com
ServerAlias www.jazila-traders.com
DocumentRoot /home/jazila-traders/public_html
ErrorLog ${APACHE_LOG_DIR}/jazila-traders_error.log
CustomLog ${APACHE_LOG_DIR}/jazila-traders_access.log combined
# CACHING CONFIGURATION
CacheQuickHandler on
CacheLock on
CacheLockPath /tmp/mod_cache_lock
CacheLockMaxAge 5
CacheIgnoreHeaders Set-Cookie
CacheDefaultExpire 3600
CacheIgnoreNoLastMod On
# Disk cache
CacheRoot /var/cache/apache2/
CacheEnable disk /
CacheDirLevels 2
CacheDirLength 1
CacheMaxFileSize 10000000
# Expire headers for static content
<FilesMatch "\.(jpg|jpeg|png|gif|ico|css|js|pdf|txt)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
Header append Cache-Control "public"
</FilesMatch>
# HTML caching
<FilesMatch "\.(html|htm)$">
ExpiresActive on
ExpiresDefault "access plus 1 hour"
</FilesMatch>
<Directory "/home/jazila-traders/public_html">
Require all granted
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
# MPM Event Configuration (in /etc/apache2/mods-available/mpm_event.conf)
<IfModule mpm_event_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 1000
</IfModule>
Virtual Host File: /etc/apache2/sites-available/jazila-traders.conf
Enable Site: sudo a2ensite jazila-traders.conf
Enable Modules: sudo a2enmod cache cache_disk expires headers
Restart Command: sudo systemctl restart apache2
; PHP 8.1 Optimized Configuration
; ========================
; MEMORY AND PERFORMANCE
; ========================
memory_limit = 256M
max_execution_time = 120
max_input_time = 120
max_input_vars = 3000
post_max_size = 64M
upload_max_filesize = 64M
; ========================
; OPCODE CACHING
; ========================
opcache.enable = 1
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 20
opcache.max_accelerated_files = 20000
opcache.revalidate_freq = 60
opcache.fast_shutdown = 1
opcache.enable_cli = 1
opcache.save_comments = 1
; ========================
; ERROR HANDLING
; ========================
display_errors = Off
log_errors = On
error_log = /var/log/php8.1-error.log
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
; ========================
; SESSION SETTINGS
; ========================
session.gc_maxlifetime = 1440
session.cookie_httponly = 1
session.cookie_secure = 1
session.use_strict_mode = 1
; ========================
; OTHER SETTINGS
; ========================
default_socket_timeout = 120
pdo_mysql.default_socket = /var/run/mysqld/mysqld.sock
mysqli.default_socket = /var/run/mysqld/mysqld.sock
cgi.fix_pathinfo = 0
date.timezone = UTC
PHP Config File: /etc/php/8.1/apache2/php.ini or /etc/php/8.1/fpm/php.ini
Check Version: php -v
Restart Apache/PHP: sudo systemctl restart apache2 or sudo systemctl restart php8.1-fpm
Complete setup commands for all services
Verify all services are running properly
Restart MySQL, Apache2, and PHP services