欢迎访问我的个人博客:我心永恒

centos 7 nginx迁移到openresty

原文地址: centos 7 nginx迁移到openresty

欢迎访问我的博客: http://blog.duhbb.com/

安装 openresty

下载部署包:openresty_centos7.zip, 包的话搜一下应该到处都有吧!

安装 openresty:

rpm -ivh openresty-*.rpm --force --nodeps

备份 nginx 配置 (本操作将会终止 nginx 服务, 请确认无误后继续操作):

service nginx stop
mv /etc/nginx /etc/nginx_nginx
mv /usr/sbin/nginx /usr/sbin/nginx_nginx
mv /usr/lib/systemd/system/nginx.service /usr/lib/systemd/system/nginx.service_nginx

配置 openresty

# 配置 openresty 配置文件
ln -s /usr/local/openresty/nginx/conf /etc/nginx

# 创建一个目录
mkdir conf.d
cp -a /etc/nginx_nginx/conf.d/*.conf /etc/nginx/conf.d/

# 备份 nginx 配置文件
mkdir /etc/nginx/conf.d/backup
cp -a /etc/nginx_nginx/nginx.conf /etc/nginx/conf.d/backup/
cp -a /etc/nginx_nginx/conf.d /etc/nginx/conf.d/backup/

# 配置 openresty 服务
ln -s /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx
ln -s /usr/lib/systemd/system/openresty.service /usr/lib/systemd/system/nginx.service
systemctl daemon-reload

# 关闭 nginx 开机启动, 开启 openresty 开机启动
systemctl disable nginx
systemctl enable openresty

将原来的 nginx 的 *.conf 的配置文件迁移过来如果没有生效, 可以看下 nginx.conf 这个文件是否把之前的 *.conf 文件引入进来了.

    sendfile        on;
    tcp_nopush     on;
    server_tokens off;
    keepalive_timeout  65;
    gzip  on;
    gzip_min_length 1024;
    gzip_buffers 32 4k;
    gzip_comp_level 6;
    gzip_types text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png image/vnd.microsoft.icon image/x-icon;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";
    # 包含分散配置的文件
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/conf.d/*.upstream;
    include /etc/nginx/conf.d/healthcheck.lua;

原文地址: centos 7 nginx迁移到openresty

欢迎访问我的博客: http://blog.duhbb.com/

posted @ 2022-05-31 13:26  tuhooo  阅读(135)  评论(0编辑  收藏  举报

欢迎访问我的个人博客:我心永恒