Shaoli's Blog

用openresty完美替换nginx, 并开启http 2.0


下载openresty

wget https://openresty.org/download/openresty-1.15.8.1.tar.gz
tar zxvf openresty-1.15.8.1.tar.gz
cd openresty-1.15.8.1


安装openresty

# 查看当前nginx的编译配置
nginx -V


如下所示, configure arguments 就是当前nginx的配置

nginx version: nginx/1.7.4
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
TLS SNI support enabled
configure arguments: --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module


编译、安装openresty,把刚才的配置加到"configure"命令后方

# HTTP2只能运行在https环境
./configure --prefix=/usr/local/openresty/nginx --with-http_ssl_module --with-http_v2_module
gmake && gmake install


更换配置文件

# 如果有ssl证书,记得也一起过去
cp /usr/local/nginx/conf/*.conf /usr/local/openresty/conf

# nginx.conf 记得加上
listen 443 ssl http2;


停止原nginx

nginx -s stop


启动openresty

/usr/local/openresty/nginx/bin/openresty



把openresty软链接到bin目录,并改名为nginx

ln -s /usr/local/openresty/nginx/bin/openresty /usr/local/bin/nginx

# 以后就可以直接使用nginx的相关操作命令了
nginx


    评论列表

  • 暂无评论...快来说说吧!
person
0 / 16
comment
0 / 100