- 安装依赖包
dos2unix start.sh
centos:
yum install readline-devel pcre-devel openssl-devel gcc git zip unzip
ubuntu:
apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl
dpkg -l | grep zlib
apt-get install openssl libssl-dev
apt-get install libpq-dev
apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g-dev zip unzip -
解压openresty压缩包
tar -xzvf openresty-VERSION.tar.gz -
解压并编译安装openresty
cd openresty-VERSION/
make
make install
4.修改nginx配置文件
修改nginx.conf文件,将内容全部删除,拷贝如下内容
include /opt/openresty/conf.d/common.conf;
5.配置普通用户dh reload nginx
chmod u+s /usr/local/openresty/nginx/sbin/nginx
6.将uag的配置文件、lua等文件上传到/opt/openresty目录下
将所有文件所属人改为iwecloud用户
chown -R dh:dh /opt/openresty
chown -R dh:dh /backup
chown -R dh:dh /usr/local/openresty/nginx/proxy_temp
chown -R dh:dh /usr/local/openresty/nginx/fastcgi_temp
chown -R dh:dh /usr/local/openresty/nginx/scgi_temp
chown -R dh:dh /usr/local/openresty/nginx/uwsgi_temp
chown -R dh:dh /usr/local/openresty/nginx/client_body_temp
同时需要配置nginx的配置 user dh;
7.使用root用户安装luarocks
wget http://luarocks.org/releases/luarocks-2.0.13.tar.gz
tar -xzvf luarocks-2.0.13.tar.gz
cd luarocks-2.0.13/
./configure —prefix=/usr/local/openresty/luajit \
—with-lua=/usr/local/openresty/luajit/ \
—lua-suffix=jit \
—with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1
make
sudo make install
8.使用luarocks安装luaxml和hmac
/usr/local/openresty/luajit/bin/luarocks install luaxml 101012-2
/usr/local/openresty/luajit/bin/luarocks install lua-resty-hmac
- 日志分割
添加logrotate配置文件
sudo vim /etc/logrotate.d/nginx
内容为:
/opt/openresty/log/.log /opt/openresty/log/**/.log /opt/openresty/log///.log /opt/openresty/log/////.log {
notifempty
daily
rotate 10
nocompress
copytruncate
postrotate
if [ -f /var/run/nginx.pid ]; then
kill -USR1 cat /var/run/nginx.pid
fi
endscript
}
备注:/opt/openresty/log/*.log为log日志位置,多个用空格分隔
10.使用dh用户启动nginx
11:修改common.conf 的配置 resolver 8.8.8.8 114.114.114.114 valid=30s;
user dh