LNMP 参数调优 ( 无注释 )

简介:

PHP FastCGI 优点

1、PHP 脚本运行速度更快。PHP 解释程序被载入内存而不用每次需要时从存储器读取,极大的提升了依靠脚本运行站点的性能。
2、需要使用的系统资源更少。由于服务器不再每次需要时都载入 PHP 解释程序,可以将站点的传输速度提升很多而不必增加 CPU 负担。
3、不需要对现有的代码作任何改动。运行在 Apache + PHP 上的程序,无需修改即可适用于 PHP 的 FastCGI。

LNMP 安装文档:http://www.cnblogs.com/wangxiaoqiangs/p/5336180.html

1、nginx.conf

user nginx nginx;
worker_processes 4;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;

worker_rlimit_nofile 51200;
events
{
  use epoll;
  worker_connections 51200;
}

http
{
  include mime.types;
  default_type application/octet-stream;

  log_format access ‘$remote_addr - $remote_user [$time_local] "$request"‘
                    ‘$status $body_bytes_sent "$http_referer"‘
                    ‘"$http_user_agent" $http_x_forwarded_for‘;

  server_tokens off;
  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  client_max_body_size 300m;

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 30;

  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;

  gzip on;
  gzip_min_length 1k;
  gzip_buffers 4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_types text/plain application/x-javascript text/css application/xml;
  gzip_vary on;

  server
  {
    listen 80;
    server_name localhost;
    index index.php index.html index.htm;
    root /usr/local/nginx/html;

    charset utf-8;

    access_log /usr/local/nginx/logs/access.log access;

    location ~ .*\.(sh|bash)?$ { return 403; }

    location ~ .*\.(php|php5)?$ {
      fastcgi_pass unix:/dev/shm/php-cgi.sock; # 127.0.0.1:9000
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
      include fastcgi_params;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires 30d;
    }

  # 该缓存配置,安装 Zabbix 中,网页上测试数据库连接时会出错 ( 测试数据库通过,跳转页面时,由于有 js 缓存,导致又跳回了没有验证时的页面,Zabbix 无法继续安装 )
  # location ~ .*\.(js|css)?$
  # {
    # expires 1h;
  # }
  }

  server
  {
    listen 8000;
    server_name localhost;

    location / {
      stub_status on;
      access_log off;
    }
  }
}

2、my.cnf(详细:http://www.cnblogs.com/wangxiaoqiangs/p/5500675.html

[client]
default-character-set = utf-8
port = 3306
socket = /tmp/mysql.sock

[mysqld]
user = mysql
port = 3306

socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data

open_files_limit = 10240
back_log = 600
max_connections = 3000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 2M
join_buffer_size = 2M
therad_cache_size = 300
thread_concurrency = 8

query_cache_size = 32M
query_cache_limit = 2M
query_cache_min_res_unit = 2K

default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 1
log_long_format

log-bin = mysql-bin
binlog_cache_size = 4M
binglog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 512M
expire_logs_days = 7

key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_max_extra_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover

skip-name-resolve
master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

server-id = 1

innodb_additional_men_pool_size = 16M
innodb_buffer_pool_size = 2048M
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0

[mysqldump]
quick
max_allowed_packet = 32M

3、php-fpm.conf (详细:http://www.cnblogs.com/wangxiaoqiangs/p/5336579.html

[global]
pid = run/php-fpm.pid
rlimit_files = 51200

[www]
user = nginx
group = nginx
;listen = 127.0.0.1:9000
listen = /dev/shm/php-cgi.sock
;listen.back_log = 65535
listen.owner = nginx
listen.group = nginx

; 进程数限制
pm = dynamic
pm.max_children = 128
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 30

; 开启慢查询日志 ( 排除原因后关闭 )
request_slowlog_timeout = 3
slowlog = var/log/$pool.slow.log

4、/etc/sysctl.conf

net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768

net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2

net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800

net.ipv4.ip_local_port_range = 1024 65535

5、/etc/security/limits.conf

* soft nofile 65535
* hard nofile 65535

6、reboot

时间: 2024-11-07 04:12:12

LNMP 参数调优 ( 无注释 )的相关文章

JVM参数调优:Eclipse启动实践

本文主要参考自<深入理解 Java 虚拟机>.这本书是国人写的难得的不是照搬代码注释的且不是废话连篇的技术书,内容涵盖了 Java 从源码到字节码到执行的整个过程,包括了 JVM(Java Virtual Machine)的架构,垃圾收集的介绍等.这里摘录出关于配置 JVM 基本参数来调优 Eclipse 启动的过程,比较初级,供初学者参考. 基础知识 针对 JVM 的参数调优主要集中在数据区大小的控制和垃圾回收策略的选择.关于 JVM 运行机制等更多内容可参考其他博文 JVM 的运行时数据区

php-fpm参数调优

关于php-fpm.conf参数调优,只对重要的参数进程调优.其它可参数前辈的. http://php.net/manual/zh/install.fpm.configuration.php (官方的) http://www.cnblogs.com/argb/p/3604340.html http://www.cnblogs.com/jonsea/p/5522018.html https://www.zybuluo.com/phper/note/89081 http://blog.64mazi.

(转)JVM参数调优八大技巧

这里和大家分享一下JVM参数调优的八条经验,JVM参数调优,这是很头痛的问题,设置的不好,JVM不断执行FullGC,导致整个系统变得很慢,网站停滞时间能达10秒以上,相信通过本文的学习你对JVM参数调优有新的认识. 实例讲解JVM参数调优的八条经验 本文将介绍JVM参数调优,这是很头痛的问题,设置的不好,JVM不断执行FullGC,导致整个系统变得很慢,网站停滞时间能达10秒以上,这种 情况如果没隔几分钟就来一次,自己都受不了.这种停滞在测试的时候看不出来,只有网站pv达到数十万/天的时候问题

民间最全的Linux系统内核参数调优说明

  相信做运维的同仁,进行运维环境初建时,必须要考虑到操作系统内核参数的优化问题,本人经历数次的运维环境重建后,决定要自行收集一份比较完善的系统内核参数优化说明文件出来,于是就有了下文,本文当前值是官方默认参数,建议参数直接添加于sysctl -a输出的结果每一行的后面,希望对运维的同仁做系统内核参数调优时有所帮助.废话不多讲,直接上干货! #3.10.0-862.el7.x86_64#CentOS Linux release 7.5.1804 abi.vsyscall32 = 1crypto.

性能测试三十六:内存溢出和JVM常见参数及JVM参数调优

堆内存溢出: 此种溢出,加内存只能缓解问题,不能根除问题,需优化代码堆内存中存在大量对象,这些对象都有被引用,当所有对象占用空间达到堆内存的最大值,就会出现内存溢出OutOfMemory:Java heap space 永久代溢出 如果发生,则是在初始化的时候,空间太小,解决办法,扩大空间类的一些信息,如类名.访问修饰符.字段描述.方法描述等,所占空间大于永久代最大值,就会出现OutOfMemoryError:PermGen space 内存溢出的检测方法:pid=1730 Jdk/bin目录下

centos 7 之haproxy的配置文件详解及haproxy参数调优

HAProxy虽然名字前有HA,但它并不是一款高可用软件,而是一款用于实现负载均衡的软件,可实现四层与七层的负载均衡. 关于haproxy的常用调度算法,可以参考博文:Haproxy支持的调度算法. haproxy的详细配置过程和配置日志记录,可以参考博文:keepalived+Haproxy搭建高可用Web群集. HAProxy虽然名字前有HA,但它并不是一款高可用软件,而是一款用于实现负载均衡的软件,可实现四层与七层的负载均衡. 这篇博文不谈如何配置haproxy,主要来聊一下它的配置文件说

inux IO 内核参数调优 之 参数调节和场景分析

http://backend.blog.163.com/blog/static/2022941262013112081215609/ http://blog.csdn.net/icycode/article/category/5966733 http://blog.sina.cn/dpool/blog/s/blog_b374c0f30102wboi.html 1. pdflush刷新脏数据条件 (linux IO 内核参数调优 之 原理和参数介绍)上一章节讲述了IO内核调优介个重要参数参数. 总

Linux6.x内核参数调优

## 本人在测试机上测试过,效果不错 fs.file-max = 6553600 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_fin_t

spark参数调优

摘要 1.num-executors 2.executor-memory 3.executor-cores 4.driver-memory 5.spark.default.parallelism 6.spark.storage.memoryFraction 7.spark.shuffle.memoryFraction 8.资源参数参考示例 内容 1.num-executors 参数说明:该参数用于设置Spark作业总共要用多少个Executor进程来执行.Driver在向YARN集群管理器申请资