1、进入openresty-1.11.2.4的压缩包木木,我这里是在“/usr/local/”下;2、进入后执行【tar -xzvf openresty-1.11.2.4.tar.gz】进行解压3、解压成功后进入“openresty-1.11.2.4”文件夹下,执行【./configure】命令4、在“openresty-1.11.2.4”文件夹下,执行完【./configure】命令后,继续执行【make】命令5、在“openresty-1.11.2.4”文件夹下,执行完【make】命令后,继续执行【make install】命令6、安装成功后在“openresty-1.11.2.4”同目录会自动创建一个“openresty”目录,这样证明就安装成功了7、进入“openresty”目录,执行【nginx】命令启动服务,访问127.0.0.1,如果显示“Welcome to nginx!”证明成功了,注意:最好在修改好所有配置后再启动,不然端口可能会和当前服务器的有冲突8、服务器重启:【nginx -s reload :修改配置后重新加载生效】如果这种方式不行就用第9条的方法/usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf9、修改了配置文件需要用【nginx -c /usr/local/openresty/nginx/conf/nginx.conf】进行重启才生效 后续:1、如果服务器要使用“resty.http” 一定要把http.lua和http_headers.lua上传到“/usr/local/openresty/lualib/resty”目录下2、ngx的默认日志地址在“/var/log/nginx”下 安装openresty需要的库
apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make build-essential 构建 OpenResty进入下载好的压缩包文件中用下面的命令进行解压 VERSION 为当前openresty的版本tar -xzvf openresty-VERSION.tar.gz 然后在进入 openresty-VERSION/ 目录, 然后输入以下命令配置(默认配置安装):./configure 编译安装下面命令进行编译
make下面的命令安装 OpenResty到系统之中make install此时,我的系统中已经安装好了Openresty,因为在配置时使用了默认安装路径,所以我的程序被安装到了:
/usr/local/openresty/中,该文件夹中包含了luajit、lualib、nginx三个目录。openresty的配置文件默认是在 /usr/local/openresty/nginx/conf 运行nginx进入目录,执行./nginx
没报错就运行起来了执行nginx -V 查看nginx 版本信息 停止服务:
nginx -s reload :修改配置后重新加载生效
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确关闭nginx:
nginx -s stop :快速停止nginx
quit :完整有序的停止nginx其他的停止nginx 方式:ps -ef | grep nginxkill -QUIT 主进程号 :从容停止Nginx
kill -TERM 主进程号 :快速停止Nginx
pkill -9 nginx :强制停止Nginx启动nginx:
nginx -c /path/to/nginx.conf平滑重启nginx:
kill -HUP 主进程号
启动服务
通过下述方式启动Nginx。如果没有任何输出,说明启动成功,-p 指定我们的项目目录,-c 指定配置文件。/usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf
/usr/local/openresty/nginx/sbin/nginx -p 'pwd' -c /usr/local/openresty/nginx/conf/nginx.conf
为openresty下的nginx建立软链(非必需)ln -s /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx
则可使用如下方式启动/usr/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf
安装成功
1、/usr/local/openresty/site/lualib里添加 resty和cjson的引用
问题解决:The program ‘nginx’ can be found in the following packages:
* nginx-extras
* nginx-full
* nginx-light
Try: apt-get install <selected package> 开始我以为是我的nginx安装错了,然后找各种教程仔细看安装步骤,觉得没有问题啊,折腾好久不知道该怎么办,最好在网友的提示下仔细看了提示,然后按照提示继续做,即:apt-get install nginx-extras 回车apt-get install nginx-full 回车apt-get install nginx-light回车