Openresty

Openresty

八月 08, 2019

Openresty

目录

[隐藏]

  • [1安装依赖]
  • [2编译安装]
  • [3systemd启动脚本]
  • [4默认nginx.conf配置]
1
yum install pcre-devel zlib-devel

编译安装

1
2
3
4
5
6
7
8
https://openresty.org/download/openresty-1.13.6.2.tar.gz
tar -xzf openresty-1.13.6.2.tar.gz
cd openresty-1.13.6.2
./configure \
--with-http_ssl_module \
--prefix=/data/soft/openresty
make -j4
make install

systemd启动脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cat > /lib/systemd/system/openresty.service << EOF
[Unit]
Description=The OpenResty HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/data/soft/openresty/nginx/logs/openresty.pid
ExecStartPre=/data/soft/openresty/nginx/sbin/nginx -t
ExecStart=/data/soft/openresty/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
EOF

chmod u+x /lib/systemd/system/openresty.service

systemctl enable openresty.service
systemctl start openresty.service

默认nginx.conf配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
user  www;
worker_processes 4;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 102400;
use epoll;
}


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

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 80 default;
server_name localhost;
return 404;
}
include vhosts/*.conf;
}