1、设置
开机主动
启动Nginx + PHP
vim /etc/rc.local
/home/mysql/mysql start
ulimit -SHn 65535
/usr/local/webserver/php/sbin/php-fpm start
/usr/local/webserver/nginx/sbin/nginx
2、优化Linux内核参数
vi /etc/sysctl.conf
末端
加上
# Add
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_len = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
#net.ipv4.tcp_fin_timeout = 30
#net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024 65535
立即
奏效适才
所设置
的
/sbin/sysctl -p
3、在不收场Nginx做事的情况下平滑变革
Nginx设置
改了/usr/local/webserver/nginx/conf/nginx.conf
用这个下令
测试
/usr/local/webserver/nginx/sbin/nginx -t
出现
假如
屏幕表现
以下两行信息,阐发
设置
文件精确
:
the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
the configuration file /usr/local/webserver/nginx/conf/nginx.conf was tested successfully
代表设置
没有任何题目
,可以放心起头推行
4、平滑重启NGINX
/usr/local/webserver/nginx/sbin/nginx -s reload
5、编写每天
定时切割Nginx日记
的脚本
vi /usr/local/webserver/nginx/sbin/cut_nginx_log.sh
#!/bin/bash
# This script run at 00:00
# The Nginx logs path
logs_path="/usr/local/webserver/nginx/logs/"
mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/
mv ${logs_path}access.log ${logs_path}$(date -d "yesterday"
+"%Y")/$(date -d "yesterday" +"%m")/access_$(date -d "yesterday"
+"%Y%m%d").log
kill -USR1 `cat /usr/local/webserver/nginx/nginx.pid`
添加到定时义务
中去
阅读(1788) | 评论(0) | 转发(1) |