Nginx installation configuration Disables the use of IP access rewrite rewrite alias settings log polling

Source: Internet
Author: User
Tags install openssl

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/71/69/wKioL1XO7D2h1Dn0AACNkbOZ8S8381.jpg "title=" 11.png "alt=" Wkiol1xo7d2h1dn0aacnkboz8s8381.jpg "/>

1. Yum Install pcre pcre-devel-y
#支持rewrite重写功能

2. Yum-y Install OpenSSL Openssl-devel
#支持https功能

3, Useradd nginx-s/sbin/nologin-m
#添加用户

4. Tar zxf nginx-1.6.2.tar.gz
CD nginx-1.6.2
./configure \
--user=nginx--group=nginx \
--prefix=/application/nginx-1.6.2 \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre

5. Make && make install

6, Ln-s/application/nginx-1.6.2/application/nginx
#做一个软链接

7,/application/nginx/sbin/nginx-t
/application/nginx/sbin/nginx
#检查并启动服务

8, Echo ' path= '/application/nginx/sbin: $PATH "' >>/etc/profile
Source/etc/profile
#添加环境变量

9. Modify the configuration file
[email protected] conf]# cat nginx.conf
Worker_processes 1;
Events {
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Sendfile on;
Keepalive_timeout 65;
Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" "$http _x_forwarded_for";

Access_log Logs/access.log Main;

#禁止使用IP访问网站
server {
Listen 80;
Location/{return 404;}
}

#设置别名
server {
Listen 80;
server_name www.cui.com cui.com;
Location/{
root/data/www;
Index index.html index.htm;
}
}

#301 Rewrite address rewriting
server {
Listen 80;
server_name www.cui.org;
Rewrite ^/(. *) $ http://www.cui.com/$1 permanent;
}
}

10. Log Polling
[email protected] scripts]# cat cut_nginx_log.sh
#!/bin/sh
Logpath= "/application/nginx/logs/" #定义存放日志的目录变量

CD $logPath
MV Access.log access_$ (date +%f). log
/application/nginx/sbin/nginx-s Reload
find/application/nginx/logs/-name access_*.log-mtime +7|xargs rm-f #保留7天的日志

11, do the scheduled task
[Email protected] scripts]# Crontab-l|tail-2
###########
XX * * * */bin/sh/server/scripts/cut_nginx_log.sh >/dev/null 2>&1


This article is from the "Shohai" blog, make sure to keep this source http://eveday.blog.51cto.com/10577430/1684860

Nginx installation configuration Disables the use of IP access rewrite rewrite alias settings log polling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.