Shadow
lnmp单机高并发配置
06/17
采用lnmp.org一键安装环境
安装前可以根据自己的需求,修改安装脚本里的内容
文件夹内部的源码包,是放在lnmp1.9/src
这个目录下的,避免再使用网络下载比较费时间
单服务高并发配置文件说明
本文件夹内的配置文件在服务器24 vCPU 96 GiB 配置的服务器可以直接使用,2000个并
服务器主要修改的内容有
## 打开文件数量
ulimit -a
ulimit -n 65536
#永久修改
#修改文件cat /etc/security/limits.conf,这个值可以改大点,不会影响什么
# End of file
root soft nofile 655350
root hard nofile 655350
* soft nofile 655350
* hard nofile 655350
# TCP最大连接数
cat /proc/sys/net/core/somaxconn
echo 20000 > /proc/sys/net/core/somaxconn
##TCP连接立即回收、回用
cat /proc/sys/net/ipv4/tcp_tw_reuse ##我的结果是1,不需要改了
cat /proc/sys/net/ipv4/tcp_tw_recycle ##我的结果是1,不需要改了
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
cat /proc/sys/net/ipv4/tcp_syncookies ##我的结果是1
echo 0 > /proc/sys/net/ipv4/tcp_syncookies ## 屏蔽TCP异步
Nginx配置信息
user www www;
worker_processes auto;
worker_cpu_affinity auto;
error_log /vdb1/wwwlogs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept off;
accept_mutex off;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
sendfile_max_chunk 512k;
tcp_nopush on;
#keepalive_timeout 60;
keepalive_timeout 0;
tcp_nodelay on;
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 256k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
#limit_conn_zone $binary_remote_addr zone=perip:10m;
##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.
server_tokens off;
access_log off;
server
{
listen 80 default_server reuseport;
#listen [::]:80 default_server ipv6only=on;
server_name _;
index index.html index.htm index.php;
root /vdb1/www/default;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /vdb1/wwwlogs/access.log;
}
include vhost/*.conf;
}
Php-fmp配置文件
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
;pm = dynamic
pm = static
;pm.max_children = 40
pm.max_children = 3000
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 40
pm.max_requests = 1024
pm.process_idle_timeout = 10s
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log
版权属于:
Dcr163的博客
本文链接:
https://dcr163.cn/692.html(转载时请注明本文出处及文章链接)