博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LNMP 参数调优 ( 无注释 )
阅读量:6292 次
发布时间:2019-06-22

本文共 4715 字,大约阅读时间需要 15 分钟。

简介:

PHP FastCGI 优点

1、PHP 脚本运行速度更快。PHP 解释程序被载入内存而不用每次需要时从存储器读取,极大的提升了依靠脚本运行站点的性能。

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

LNMP 安装文档:

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(详细:)

[client]default-character-set = utf-8port = 3306socket = /tmp/mysql.sock[mysqld]user = mysqlport = 3306socket = /tmp/mysql.sockbasedir = /usr/local/mysqldatadir = /usr/local/mysql/dataopen_files_limit = 10240back_log = 600max_connections = 3000max_connect_errors = 6000table_cache = 614external-locking = FALSEmax_allowed_packet = 32Msort_buffer_size = 2Mjoin_buffer_size = 2Mtherad_cache_size = 300thread_concurrency = 8query_cache_size = 32Mquery_cache_limit = 2Mquery_cache_min_res_unit = 2Kdefault-storage-engine = MyISAMthread_stack = 192Ktransaction_isolation = READ-COMMITTEDtmp_table_size = 246Mmax_heap_table_size = 246Mlong_query_time = 1log_long_formatlog-bin = mysql-binbinlog_cache_size = 4Mbinglog_format = MIXEDmax_binlog_cache_size = 8Mmax_binlog_size = 512Mexpire_logs_days = 7key_buffer_size = 256Mread_buffer_size = 1Mread_rnd_buffer_size = 16Mbulk_insert_buffer_size = 64Mmyisam_sort_buffer_size = 128Mmyisam_max_sort_file_size = 10Gmyisam_max_extra_sort_file_size = 10Gmyisam_repair_threads = 1myisam_recoverskip-name-resolvemaster-connect-retry = 10slave-skip-errors = 1032,1062,126,1114,1146,1048,1396server-id = 1innodb_additional_men_pool_size = 16Minnodb_buffer_pool_size = 2048Minnodb_data_file_path = ibdata1:1024M:autoextendinnodb_file_io_threads = 4innodb_thread_concurrency = 8innodb_flush_log_at_trx_commit = 2innodb_log_file_size = 128Minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 90innodb_lock_wait_timeout = 120innodb_file_per_table = 0[mysqldump]quickmax_allowed_packet = 32M

3、php-fpm.conf (详细:)

[global]pid = run/php-fpm.pidrlimit_files = 51200[www]user = nginxgroup = nginx;listen = 127.0.0.1:9000listen = /dev/shm/php-cgi.sock;listen.back_log = 65535listen.owner = nginxlisten.group = nginx; 进程数限制pm = dynamicpm.max_children = 128pm.start_servers = 20pm.min_spare_servers = 10pm.max_spare_servers = 30; 开启慢查询日志 ( 排除原因后关闭 )request_slowlog_timeout = 3slowlog = var/log/$pool.slow.log

4、/etc/sysctl.conf

net.ipv4.tcp_max_syn_backlog = 65536net.core.netdev_max_backlog = 32768net.core.somaxconn = 32768net.core.wmem_default = 8388608net.core.rmem_default = 8388608net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.ipv4.tcp_timestamps = 0net.ipv4.tcp_synack_retries = 2net.ipv4.tcp_syn_retries = 2net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_mem = 94500000 915000000 927000000net.ipv4.tcp_max_orphans = 3276800net.ipv4.ip_local_port_range = 1024 65535

5、/etc/security/limits.conf

* soft nofile 65535* hard nofile 65535

6、reboot

转载于:https://www.cnblogs.com/wangxiaoqiangs/p/5500709.html

你可能感兴趣的文章
Laravel5.0学习--01 入门
查看>>
时间戳解读
查看>>
sbin/hadoop-daemon.sh: line 165: /tmp/hadoop-hxsyl-journalnode.pid: Permission denied
查看>>
@RequestMapping 用法详解之地址映射
查看>>
254页PPT!这是一份写给NLP研究者的编程指南
查看>>
《Data Warehouse in Action》
查看>>
String 源码浅析(一)
查看>>
Spring Boot 最佳实践(三)模板引擎FreeMarker集成
查看>>
Fescar 发布 0.2.3 版本,支持 Redis 和 Apollo
查看>>
Google MapReduce到底解决什么问题?
查看>>
CCNP-6 OSPF试验2(BSCI)
查看>>
Excel 2013 全新的图表体验
查看>>
openstack 制作大于2TB根分区自动扩容的CENTOS镜像
查看>>
Unbuntu安装遭遇 vmware上的Easy install模式
查看>>
几个常用的ASP木马
查看>>
python分析postfix邮件日志的状态
查看>>
Mysql-5.6.x多实例配置
查看>>
psutil
查看>>
在git@osc上托管自己的代码
查看>>
机器学习算法:朴素贝叶斯
查看>>