文章目录
- 1.解压
- 2.安装
1.解压
压缩包放在/usr/local,进入此路径解压
tar-zxvfopenresty-1.19.3.1.tar.gz2.安装
将解压目录更名并进入
mvopenresty-1.19.3.1 openrestycdopenresty编译安装
./configure&&make&&makeinstall编译安装过程中有可能会出错,提示:error: the HTTP rewrite module requires the PCRE library或者error: the HTTP cache module requires md5 functions from OpenSSL library,需安装OpenSSL依赖:
#如果缺少PCRE或OpenSSL依赖,用此命令安装yum-yinstallpcre-devel openssl openssl-devel也可能会出现:ERROR: failed to run command: gmake TARGET_STRIP=@: CCDEBUG=-g XCFLAGS=‘-DLUAJIT_ENABLE_LUA52COMPAT’ CC=cc PREFIX=/usr/local/openresty/luajit…,这时候需要安装C 编译器:
#如果缺少C 编译器(cc),用此命令安装yum-yinstallgcc环境变量配置nginx或openresty都行
上述两个路径都可以做环境变量路径
编辑profile
vim/etc/profile末尾加以下配置
#nignxexportNGINX_HOME=/usr/local/openresty/nginx/exportPATH=$PATH:$NGINX_HOME/sbin配置后不要忘了刷新
source/etc/profile添加Nginx服务
vim/usr/lib/systemd/system/nginx.service内容粘贴进去
[Unit]Description=nginxAfter=network.target[Service]Type=forkingExecStart=/usr/local/openresty/bin/openresty-c/usr/local/openresty/nginx/conf/nginx.confExecReload=/usr/local/openresty/bin/openresty-sreloadExecStop=/usr/local/openresty/bin/openresty-squitPrivateTmp=true[Install]WantedBy=multi-user.target
允许自启动并开启redis
systemctlenablenginx systemctl start nginx systemctl status nginx
注意服务名设置的是nginx,如果是openresty,就是systemctl … openresty