Nginx优化配置

php中文网
发布: 2016-08-08 09:21:45
原创
1254人浏览过

cat nginx.conf
##
user webroot webroot;
worker_processes  8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; 
worker_rlimit_nofile 102400;
events {
    use epoll;
    worker_connections  204800;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  60;
server_names_hash_bucket_size 128; 
client_header_buffer_size 32k; 
large_client_header_buffers 4 32k;
open_file_cache max=102400 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
client_max_body_size 8m;       
tcp_nopush     on;
tcp_nodelay on; 
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; 
fastcgi_cache_path /service/nginx/fastcgi_cache levels=1:2 keys_z inactive=5m max_size=1g;
fastcgi_connect_timeout 300; 
fastcgi_send_timeout 300; 
fastcgi_read_timeout 300; 
fastcgi_buffer_size 64k; 
fastcgi_buffers 8 64k; 
fastcgi_busy_buffers_size 128k; 
fastcgi_temp_file_write_size 128k; 
##
    server {
        listen       80;
        server_name  www.zhoupeihao.com zhoupeihao.com;
root   /data/web/www;
            index  index.html index.php index.htm index.shtml;
        
        location / {
            try_files $uri $uri/ /index.php?$args;
}
    location /ngx_status
{
        stub_status on;
        access_log off;
    }        
        location ~ .*\.(php)?$
        {
        expires -1s;
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:9000;
fastcgi_cache fcgi;
fastcgi_cache_valid 200 302 1h; 
fastcgi_cache_valid 301     1d; 
fastcgi_cache_valid any     1m; 
fastcgi_cache_min_uses 1; 
fastcgi_cache_use_stale error timeout invalid_header http_500; 
        }
    }
}
cat >>/etc/sysctl.conf #for web
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_tw_recycle = 1 
net.ipv4.tcp_tw_reuse = 1 
net.ipv4.tcp_syncookies = 1 
net.core.somaxconn = 262144 
net.core.netdev_max_backlog = 262144 
net.ipv4.tcp_max_orphans = 262144 
net.ipv4.tcp_max_syn_backlog = 262144 
net.ipv4.tcp_timestamps = 0 
net.ipv4.tcp_synack_retries = 1 
net.ipv4.tcp_syn_retries = 1 
net.ipv4.tcp_fin_timeout = 1 
net.ipv4.tcp_keepalive_time = 30 
EOF

版权声明:本文为博主原创文章,未经博主允许不得转载。

琅琅配音
琅琅配音

全能AI配音神器

琅琅配音 208
查看详情 琅琅配音

以上就介绍了Nginx优化配置,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号