linu编译安装及配置Ngin

上传人:lcm****20 文档编号:45081373 上传时间:2018-06-15 格式:DOC 页数:5 大小:30.50KB
返回 下载 相关 举报
linu编译安装及配置Ngin_第1页
第1页 / 共5页
linu编译安装及配置Ngin_第2页
第2页 / 共5页
linu编译安装及配置Ngin_第3页
第3页 / 共5页
linu编译安装及配置Ngin_第4页
第4页 / 共5页
linu编译安装及配置Ngin_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《linu编译安装及配置Ngin》由会员分享,可在线阅读,更多相关《linu编译安装及配置Ngin(5页珍藏版)》请在金锄头文库上搜索。

1、linux 编译安装及配置编译安装及配置 Nginx(包含包含 pcre), 日志定时切割日志定时切割 安装安装 pcre(Nginxpcre(Nginx 的的 UrlrewriteUrlrewrite 模块依赖模块依赖 PCRE)PCRE)# wget ftp:/ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre- 8.12.tar.gz# tar zxvf pcre-8.12.tar.gz# cd pcre-8.12# ./configure -prefix=/usr/local/webserver/pcre# make then ma

2、ke distclean; fi worker_processes 8; error_log /var/log/nginx/nginx_error.log crit; pid /usr/local/webserver/nginx/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; http include mime.

3、types;default_type application/octet-stream;#charset gb2312;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 8m;sendfile on;tcp_nopush on;keepalive_timeout 60;tcp_nodelay on;fastcgi_connect_timeout 300;fastcgi_send_timeout 300;fas

4、tcgi_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

5、 on;#limit_zone crawler $binary_remote_addr 10m;server listen 80;server_name 114.80.232.167;index index.html index.htm index.php;root /opt/www;#limit_conn crawler 20;location .php fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fcgi.conf;location .*.(gif|jpg|jpeg|png|bmp|swf)$ expires 30

6、d;location .*.(js|css)?$ expires 1h;location /status/ stub_status on;access_log off;log_format access $remote_addr - $remote_user $time_local “$request“ $status $body_bytes_sent “$http_referer“ “$http_user_agent“ $http_x_forwarded_for;access_log /var/log/nginx/access.log access; = 在在/usr/local/webse

7、rver/nginx/conf/usr/local/webserver/nginx/conf/目录中创建目录中创建 fcgi.conffcgi.conf 文件文件#vi /usr/local/webserver/nginx/conf/fcgi.conf =复制以下内容,保存fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;fastcgi_split_path_info (.*.php)(.*)$;fastcgi_param PATH_INFO $fastcgi_path

8、_info; = 启动启动 NginxNginx#ulimit -SHn 51200使用 ulimit -a 可以查看当前系统的所有限制值,使用 ulimit -n 可以 查看当前的最大打开文件数。新装的 linux 默认只有 1024,当作负载较大的服务器时,很容易遇到error: too many open files。因此,需要将其改大。使用 ulimit -n 65535 可即时修改,但重启后就无效了。 (注 ulimit - SHn 65535 等效 ulimit -n 65535,-S 指 soft,-H 指 hard)#/usr/local/webserver/nginx/sbi

9、n/nginx -启动设定 web 目录 每天定时切割每天定时切割 NginxNginx 日志日志#vi /usr/local/webserver/nginx/sbin/cut_nginx_log.sh =输入以下内容, 保存:#!/bin/bash # This script run at 00:00# The Nginx logs path logs_path=“/var/log/nginx/“ logs_bak_path=“/var/log/nginx_bak/“mkdir -p $logs_bak_path$(date -d “yesterday“ +“%Y“)/$(date -d “

10、yesterday“ +“%m“)/ cp $logs_pathaccess.log $logs_bak_path$(date -d “yesterday“ +“%Y“)/$(date - d “yesterday“ +“%m“)/access_$(date -d “yesterday“ +“%Y%m%d“).log rm -rf $logs_path*.log kill -USR1 cat /usr/local/webserver/nginx/nginx.pid =#crontab -e -设置 crontab,每天凌晨 00:00 切割 nginx 访问日 志=输入以下内容00 00 * * * /bin/bash /usr/local/webserver/nginx/sbin/cut_nginx_log.sh

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号