#添加另一个域名,在浏览器中输入 etiantian.org,总是调到 www.etiantian.org server {
listen 80;
server_name www.etiantian.org etiantian.org;
root html/www;
index index.html index.htm;
Nginx301 跳转
301 跳转:rewrite 模块 vim nginx.conf server {
listen 80;
server_name www.etiantian.org etiantian.org;
root html/www;
index index.html index.htm;
rewrite ^/(.*) http://www.baidu.com/$1 permanent; #添加这行跳转到 baidu
Nginx 定时切割日志脚本
1. 创建脚本/application/nginx/sbin/cut_nginx_log.sh
2. vi /opt/nginx/logs/cut_nginx_log.sh
3.
#!/bin/bash
#author:ley
#date:2014-12-15
#content:cut the nginx's log at 00:00
#qq:xxxx logs_path="/opt/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 /opt/nginx/logs/nginx.pid`
4. crontab -e
00 00 * * * /bin/bash /opt/nginx/logs/cut_nginx_log.sh
方法二:
[root@Liangenyu logs]# mv www.access.log www.access_$(date +%F -d -1day).log
[root@Liangenyu logs]# /application/nginx/sbin/nginx -s reload
#编写脚本
[root@Liangenyu logs]# vim cut.nginx.log cd /application/nginx/logs && \
/bin/mv www.access.log www.access_$(date +%F -d -1day).log
/application/nginx/sbin/nginx -s reload
#添加到定时任务
30 19 * * * /bin/sh cut.nginx.log >/dev/null 2>&1