1、下载源码和依赖:
虚拟机linux环境为:14.04.1-Ubuntu
openresty源码,http://openresty.org/cn/download.html,找到源码后,下载到linux环境,比如/opt目录下,tar -zxvf openresty-1.15.8.1.tar.gz 解压
此时先不要编辑,因为openresty还有一些依赖项需要安装。将要使用的编译参数为:
./configure --with-debug --prefix=/opt/openresty/ --user=root --group=root --with-pcre=/opt/openresty_third/pcre-8.40 --with-zlib=/opt/openresty_third/zlib-1.2.11 --with-openssl=/opt/openresty_third/openssl-1.0.2q --with-http_ssl_module --add-module=/opt/nginx-rtmp-module --with-cc-opt="-g -O0"
上面参数,--prefix=/opt/openresty/表示 openresty将要被安装到的目录。--with-pcre=/opt/openresty_third/pcre-8.40表示pcre被安装到的目录。依次类推。
依赖项,openssl,pcre-8.40,zlib-1.2.11。其中pcre可以去ftp://ftp.pcre.org/pub/pcre/查找下载。依赖项都需要进行解压,如果找不到,可以私信发你。
本工程放到如下目录:
tar -zxvf openssl-1.0.2q.tar.gz
cd openssl-1.0.2q/
sudo ./configure
sudo make
sudo make install
2、编译安装
进入 /opt/openresty/ 目录下,编译,
./configure --with-debug --prefix=/opt/openresty/ --user=root --group=root --with-pcre=/opt/openresty_third/pcre-8.40 --with-zlib=/opt/openresty_third/zlib-1.2.11 --with-openssl=/opt/openresty_third/openssl-1.0.2q --with-http_ssl_module --add-module=/opt/nginx-rtmp-module --with-cc-opt="-g -O0"
make
make install
可以看到在/opt/openresty下生成了运行目录。
添加nginx环境变量到系统,/etc/profile
root@ubuntu:/usr/local/bin# /opt/openresty/nginx/sbin/nginx -s reload
root@ubuntu:/usr/local/bin# curl 127.0.0.1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to OpenResty!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to OpenResty!</h1>
<p>If you see this page, the OpenResty web platform is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="https://openresty.org/">openresty.org</a>.<br/>
Commercial support is available at
<a href="https://openresty.com/">openresty.com</a>.</p>
<p><em>Thank you for flying OpenResty.</em></p>
</body>
</html>
也可以在windows浏览器访问,