linux 安装OpenRestry

一、OpenRestry官网

openRestry中文官网

openRestry英文官网

二、OpenRestry搭建

可以参考官方提供的网址进行搭建:OpenRestry安装官网

三、开始安装

1、安装依赖库

bash 复制代码
yum install libtermcap-devel ncurses-devel libevent-devel readline-devel pcre-devel gcc openssl openssl-devel per perl wget

2、下载安装包

bash 复制代码
wget https://openresty.org/download/openresty-1.11.2.5.tar.gz

3、解压安装包

bash 复制代码
tar -xf openresty-1.11.2.5.tar.gz

4、进入安装包、安装

bash 复制代码
#进入安装包
cd openresty-1.11.2.5

#安装
./configure --prefix=/usr/local/openresty --with-luajit --without-http_redis2_module --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --add-module=/usr/local/gupao/ngx_cache_purge-2.3/

#编译并安装
make && make install

说明:

--prefix=/usr/local/openresty:安装路径

--with-luajit:安装luajit相关库,luajit是lua的一个高效版,LuaJIT的运行速度比标准Lua快数十倍。

--without-http_redis2_module:现在使用的Redis都是3.x以上版本,这里不推荐使用Redis2,表示不安装redis2支持的lua库

--with-http_stub_status_module:Http对应状态的库

--with-http_v2_module:对Http2的支持

--with-http_gzip_static_module:gzip服务端压缩支持

--with-http_sub_module:过滤器,可以通过将一个指定的字符串替换为另一个字符串来修改响应

--add-module=/usr/local/gupao/ngx_cache_purge-2.3/:Nginx代理缓存清理工具

/usr/local/openrestry/nginx目录下是安装好的nginx,以后我们将在该目录的nginx下实现网站发布

5、配置环境变量

bash 复制代码
vi /etc/profile

export PATH=/usr/local/openresty/nginx/sbin:$PATH

source /etc/profile

6、开机启动

linux系统结构/lib/systemd/system/目录,该目录自动存放启动文件的配置位置,里面一般包含有xxx.service,例如systemctl enable nginx.service,就是调用 /lib/systemd/system/nginx.service文件,使nginx开机启动。

我们可以创建/usr/lib/systemd/system/nginx.service,在该文件中编写启动nginx脚本:

Service

Type=forking

PIDFile=/usr/local/openresty/nginx/logs/nginx.pid

ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t

ExecStart=/usr/local/openresty/nginx/sbin/nginx

ExecReload=/bin/kill -s HUP $MAINPID

ExecStop=/bin/kill -s QUIT $MAINPID

PrivateTmp=true

Install

WantedBy=multi-user.target

执行systemctl daemon-reload:重新加载某个服务的配置文件

执行systemctl enable nginx.service:开机启动

执行systemctl start nginx.service:启动nginx

访问http://192.168.86.128/,效果如下:

相关推荐
小比特_蓝光10 分钟前
匿名管道+进程池
linux
BS_Li1 小时前
【Linux网络编程】NAT、代理服务、内网穿透
linux·网络·智能路由器
用户029266661332 小时前
Linux 用户管理知识与应用实践(三:用户组及修改用户密码)
linux
Mortalbreeze3 小时前
深入 Linux 线程机制(三):线程互斥——竞争条件与互斥锁的本质
linux·运维·服务器·c++·算法
鱼听禅3 小时前
CentOS 源码模式配置SVNAdmin2管理SVN仓库
linux·svn·centos
Amonter3 小时前
RK3399ProD移植主线Linux内核
linux·rockchip·rk3399pro
从零开始的代码生活_3 小时前
Linux select 多路转接详解
linux·运维·服务器·网络·网络协议·tcp/ip·计算机网络
say_fall4 小时前
【Git 精品详解】企业规范:企业级开发模型、Git Flow、发版流程规范、Code Owner 制度、事故应急回滚
大数据·linux·服务器·git·学习·elasticsearch
一杯奶茶¥4 小时前
Ubuntu系统镜像各个版本下载Ubuntu镜像合集资源Linux系统镜像乌班图Linux系统镜像
linux·运维·ubuntu·镜像·;inux镜像·ubuntu镜像
三84414 小时前
文件查找/文件压缩/解压缩
linux·运维·服务器