作者:RayChiu_Labloy
版权声明:著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处
目录
1.安装这些依赖:
2.安装openresty
3.然后
4.为了之后执行方便可以将nginx二进制文件加入到PATH中:
5.重启并加载指定目录下openresty的各种配置文件
安装过程遇到的问题:
1.openssl这个安装了但是执行 ./configure时还是一直报:
2.openresty和nginx两种方式部署linux后发现index.9ffdaeb8.css这种文件以octet-stream这种类型加载的,应该是文件解析类型不对,导致样式加载不出来。最终配合mime.types文件的nginx配置(重要的是http块的前两行):
3.access_by_lua与content_by_lua的区别:
gcc zlib zlib-devel pcre-devel openssl openssl-devel postgresql
尤其是最后四个,离线不能yum,只能下载好的rpm包,然后 rpm -ivh **.rpm安装,这些包还有一些依赖的rpm方法依然如此,如果依赖的找不到,可以找一个有网络的服务器,利用
yum install --downloadonly --downloaddir /var/cache/yum/x86_64/7/updates/packages/ openssl
这样的方式可以把rpm下载到指定位置,上传到自己的服务器安装就行
tar xzvf openresty-1.19.3.1.tar.gz # 解压
cd openresty-1.19.3.1/
./configure --prefix=/opt/openresty --with-luajit --without-http_redis2_module --with-http_iconv_module --with-http_postgres_module --with-openssl=/opt/openssl-1.1.1g
make &&make install
cd /opt/openresty
会看到有个nginx目录,没错这就是nginx,和原生的用法一样,我们直接可以执行命令来启动nginx
nginx/sbin/nginx
echo "export PATH=$PATH:/opt/openresty/nginx/sbin" >> /etc/profile && source /etc/profile
nginx -s reload -p openresty-test
配置文件截图:
./configure: error: SSL modules require the OpenSSL
需要把openssl-1.1.1g源码下载好, 并且配置到命令参数里:
./configure --prefix=library /opt/openresty --with-luajit --without-http_redis2_module --with- http_iconv_module --with-http_postgres_module --with-openssl=/opt/openssl-1.1.1g
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
# Update charset_types due to updated mime.types
charset_types text/xml text/plain text/vnd.wap.wml application/x-javascript application/rss+xml text/css application/javascript application/json;
server {
listen 8002;
server_name localhost;
location / {
root /data/dist/;
try_files $uri $uri/ /index.html;
add_header 'Access-Control-Allow-Origin' '*' always;
}
}
}
1.二者是nginx对于请求的不同处理阶段。
2.access_by_lua在请求访问阶段处理,用于访问控制,适用于http、server、location、location if。
3.content_by_lua是内容处理器,接受请求并输出响应,适用于location、location if。
【如果对您有帮助,交个朋友给个一键三连吧,您的肯定是我博客高质量维护的动力!!!】