# 在httpd.conf中修改以下参数
KeepAlive On
KeepAliveTimeout 2-5
MaxKeepAliveRequests 100
TimeOut 30-60
# 多处理模块(MPM)优化
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 150
MaxConnectionsPerChild 10000
mod_rewrite
, mod_deflate
, mod_expires
除外mod_deflate
mod_expires
[mysqld]
innodb_buffer_pool_size = 总内存的50-70%
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2 (非关键数据)
innodb_flush_method = O_DIRECT
query_cache_size = 64M
tmp_table_size = 64M
max_heap_table_size = 64M
table_open_cache = 4000
OPTIMIZE TABLE tablename;
memory_limit = 128M
max_execution_time = 30
upload_max_filesize = 20M
post_max_size = 21M
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 10
通过以上综合优化措施,可以显著提升LAMP栈网站的性能和响应速度。建议每次修改后都进行性能测试,确保优化效果。