yiduzixin@163.com | 发布于 2021-12-27 11:33:49 | 阅读量 132 |
发布于 2021-12-27 11:33:49 |

 

安装依赖

yum -y install readline-devel pcre-devel openssl-devel

安装openresty

wget https://openresty.org/package/centos/openresty.repo -O /etc/yum.repos.d/openresty.repo
# 更新yum索引
yum check-update
yum -y install openresty
# 安装命令行工具
yum -y install openresty-resty   # 命令行工具 opm 在 openresty-opm 包里,而 restydoc 工具在 openresty-doc 包里头
# 列出所有 openresty 仓库里头的软件包
# yum --disablerepo="*" --enablerepo="openresty" list available
systemctl enable openresty.service
systemctl start openresty.service
# 加入环境变量
vim -b /etc/profile
'''
OPENRESTY_HOME=/usr/local/openresty
export PATH=${OPENRESTY_HOME}/nginx/sbin:$PATH
'''
source /etc/profile

 配置轮询日志

mkdir /var/log/openresty
cat /etc/logrotate.d/openresty
'''
/var/log/openresty/*.log {
    create 0640 root root
    daily
    dateext
    rotate 30
    missingok
    notifempty
    compress
    sharedscripts
    postrotate
        /bin/kill -USR1 `cat /usr/local/openresty/nginx/logs/nginx.pid 2>/dev/null` 2>/dev/null || true
    endscript
}
'''
# 重启rsyslog
systemctl restart rsyslog.service

 修改配置文件

mkdir -p /home/wwwroot/error
mkdir /usr/local/openresty/nginx/conf/conf.d
cat /usr/local/openresty/nginx/conf/nginx.conf
'''
user root;
worker_processes auto;
error_log /var/log/openresty/error.log;
pid /usr/local/openresty/nginx/logs/nginx.pid;

events {
    worker_connections 65535;
}

http {
	include       mime.types;
	default_type  application/octet-stream;

	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  /var/log/openresty/access.log  main;

  sendfile            on;
  tcp_nopush          on;
  tcp_nodelay         on;
  keepalive_timeout   65;
  types_hash_max_size 4096;

  gzip  on;

  client_max_body_size 256M;
  server_tokens off;

  include /usr/local/openresty/nginx/conf/conf.d/*.conf;

  server {
    listen       80;
    listen       [::]:80;
    server_name  _;

    access_log  /var/log/openresty/unknown_access.log  main;
    root  /home/wwwroot/error;

    location / {
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   html;
    }
  }
}
'''
# 重新加载配置文件
nginx -s reload

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


内容更新于: 2021-12-28 16:03:53
链接地址: http://blog.leanote.com/post/yiduzixin@163.com/%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2

上一篇: OpenResty-waf部署

下一篇: sonarqube在centos7上部署

132 人读过
立即登录, 发表评论.
没有帐号? 立即注册
0 条评论
文档导航